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
0
47
Maintainable Integration Testing in React
Matija Marohnić
February 22, 2018
Tweet
Share
More Decks by Matija Marohnić
See All by Matija Marohnić
Goodbye jsdom/happy-dom, hello Vitest Browser Mode!
silvenon
0
9
Introduction to Remix
silvenon
0
140
Cypress vs. Playwright
silvenon
0
160
Studying Strapi: an open source head headless CMS
silvenon
0
47
CSS Specificity
silvenon
0
39
Make your JavaScript projects more accessible to newcomers
silvenon
0
76
React Hooks
silvenon
0
83
PostCSS
silvenon
0
45
CSS Custom Properties
silvenon
0
40
Other Decks in Programming
See All in Programming
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
310
Pythonではじめるオープンデータ分析〜書籍の紹介と書籍で紹介しきれなかった事例の紹介〜
welliving
3
750
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
160
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
210
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
180
Python札幌 LT資料
t3tra
7
1.1k
ゆくKotlin くるRust
exoego
1
190
はじめてのカスタムエージェント【GitHub Copilot Agent Mode編】
satoshi256kbyte
0
140
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
430
Cell-Based Architecture
larchanjo
0
160
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
1
460
Grafana:建立系統全知視角的捷徑
blueswen
0
270
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
110
Discover your Explorer Soul
emna__ayadi
2
1k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.3k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
530
Crafting Experiences
bethany
0
25
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
So, you think you're a good person
axbom
PRO
0
1.9k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
280
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.9k
Building Adaptive Systems
keathley
44
2.9k
Ruling the World: When Life Gets Gamed
codingconduct
0
120
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