Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Maintainable Integration Testing in React
Search
Matija Marohnić
February 22, 2018
Programming
59
0
Share
Maintainable Integration Testing in React
Matija Marohnić
February 22, 2018
More Decks by Matija Marohnić
See All by Matija Marohnić
oxlint & oxfmt: linting and formatting from the future
silvenon
0
28
Goodbye jsdom/happy-dom, hello Vitest Browser Mode!
silvenon
0
17
Introduction to Remix
silvenon
0
150
Cypress vs. Playwright
silvenon
0
170
Studying Strapi: an open source head headless CMS
silvenon
0
55
CSS Specificity
silvenon
0
59
Make your JavaScript projects more accessible to newcomers
silvenon
0
89
React Hooks
silvenon
0
91
PostCSS
silvenon
0
61
Other Decks in Programming
See All in Programming
空間オーディオの活用
objectiveaudio
0
150
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1.1k
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
1
360
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
2k
Making the RBS Parser Faster
soutaro
0
720
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
180
Agentic Elixir
whatyouhide
0
450
Agentic AI & UI: Arcitecture, HITL, Emerging Standards
manfredsteyer
PRO
0
100
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
190
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
440
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
3
950
Back to the roots of date
jinroq
0
860
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
360
Optimizing for Happiness
mojombo
378
71k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Paper Plane
katiecoart
PRO
1
50k
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
410
The Mindset for Success: Future Career Progression
greggifford
PRO
0
330
Transcript
None
Matija Marohnić @silvenon
Maintainable Integration Testing in React
Integration testing Unit testing End-to-end testing
Unit testing Are isolated parts of this feature working?
Integration testing Is this feature supposed to work?
End-to-end testing Does this feature actually work in a real
browser?
$$$ ¢ E2E Integration Unit Testing pyramid
•flaky/brittle •“too much of a hassle” •some features are hard
to test Case against frontend testing
•flaky → pass and fail with the same code •brittle
→ easily broken Flaky/brittle
•an afterthought, something to “deal with later” •not considered an
essential part of development “Too much of a hassle”
•e.g. some advanced APIs •async doesn’t help, it’s often about
timing •developers skip challenging tests, but never return Some features are hard to test
None
•integration tests focus on features •unit tests focus on implementation
details Why “mostly integration”?
How do you feel after writing a test?
None
–Me “A test is useless if you’re equally likely to
make a mistake in the implementation and the test itself.”
•usually developers strive towards 100% •important in libraries and APIs
•not really in frontend application code Test coverage
“You should write tests”
Testing in React
•simulating events •traversing through the tree •mounting in the DOM
or shallow rendering React test utilities
Mounting
Shallow rendering
Shallow vs. mount Unit vs. integration
•a complete testing framework •built-in jsdom •powerful assertions •easy mocking
Jest
•Enzyme •built on top of React’s test utilities •useful high-level
API •Nock •imitates a server Companion tools
Example: DataGrid
None
•opening a DataGrid displays features of the currently selected layer
Testing features Do Don’t •opening a DataGrid makes a certain API request
None
•creating a filter causes features to reduce to an expected
set Testing features Do Don’t •creating a filter displays a chip component
What about the API?
Nock
Nock
•battle-testing some modules in a cheap way •a disposable crutch
during development So when to unit test?
None
If the whole thing works together, chances are that its
parts are working as well