Skip to content

Instantly share code, notes, and snippets.

@ncuillery
Last active September 26, 2016 18:52
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncuillery/2d4a0757c7855b6770a1fddeac5e06d5 to your computer and use it in GitHub Desktop.
Save ncuillery/2d4a0757c7855b6770a1fddeac5e06d5 to your computer and use it in GitHub Desktop.
[LT Reactive 2016] Efficient testing with Jest
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$..........................................$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........................... ... .........I$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........................................$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....I$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....Z$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:...~$$$$$$$$$$$$$$$$$$$$$$$$$$$$....I$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$$$?. ..$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:....$$$$$$$$$$$$:I$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$..$$$$$$$$$$$$....Z$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$+....$$$$$$$$$Z....Z$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$.....,$$$$$$$$?....$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$7....$$$$$$$. .....+$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$I........$$$$$$~....$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$I....Z$$$$....$?....Z$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$. ..7$$Z....7$$.....$$$~...~$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$.....Z$$$....=$$....$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$I?7$$Z$$$$$$$$$$$$$....I~....$$$$$$....Z,...,$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$..........$$$$$$$$$$Z...........$$$$$$$I...........IZ$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$,.............$Z$$$$$ .... .......:Z$$$$$~..  ..... ...$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$,....7$$$$$.....$$$$$.....$$$$$=....:Z$$$~....=$$$$$.....Z$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$....$$$$$$$$.....$$$....?Z$$$$$$$....$$$$....$$$$$$$$?....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$,...$$$$$$$$$$....$$$....$$$$$$$$$7..........$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$,...$$$$$$$$$$....$$$....$$$$$$$$$$........ .$$$$$$$$$$.. .$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$+. .?$$$$$$$$=....$$$....$$$$$$$$$,...,,,.....$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$.  .,$$$$$$~....Z$$$$....7$$$$$$.....$$$$.....$$$$$$$....7$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$..............$$$$$$I..............Z$$$$$.... ..  . . ..$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$............Z$$$$$$$$...........=Z$$$$$$$:.. .. .   ....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$. ..... ..+$$$$$$$$$$Z........,$Z$$$$$$$$$$Z$:.....IZ....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$....,Z~...~$$$$$$$$$$~....,Z$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$=....$$=. .:$$$$$$$$$.....+$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$....$$$$. ..$$$$$$$......$Z$$$$$$$$$$$$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$I...:$$$$: ...$$$:......ZZ$$$$$$$$$$$$$$$$$$$$$$$$$$$$$,....$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$....$$$$$$............$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$,....$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$....$$$$$$$~........$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$. ...$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$....Z$$$$$$$$7..,Z$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.......$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$....Z$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$=.............$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.. ..............Z$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$....$$$$$$$$$$$$$$$$$$$$$$$$$$$$,... . ........~$Z$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$+....$$$$$$$$$$$$$$$$$$$$$$ZZ. ........$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$.....$$$$$$$$$$$$$$$$$$$7. .. ....$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$.....$$$$$$$$$$$$$$$I.........ZZ$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$.......$$$$Z$$$~...   ...=$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$I....... .  .  . ....$ZZ$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$..............,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$7~::+Z$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Jest is the test runner -and I quote its contributing guide- “used to ship code to everybody on facebook.com”. It's the React and React Native test runner and it's used as a day-to-day tool by the team engineers. Either you've never heard about it or you've given a try to it some months ago, you may be wondering how Jest could assume such a responsibility ?

Well, it’s true that Jest hasn’t followed the same adoption curve as other parts of React ecosystem. It wasn't well maintained, the configuration and setup process wasn't great and it was slower than expected. But unlike React, Jest had been open-sourced very early and today most of these points should be considered as youth problems since it is well supported by Facebook and the community.

I’ll talk about the recent updates (parallel execution, Babel integration, file watching) and the killing features (auto-mocking, browserless testing) which make Jest a solid and awesome alternative to the existing test runners for any CommonJS environment, including React apps !

Please ⭐ this gist if you'd like to heard about Jest at Reactive 2016 in Slovakia ! ✈️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment