Migrate to Jest (mostly)
See original GitHub issue- Karma + Jasmine + PhantomJS is slow.
- PhantomJS is unstable. (CI has been failing since b5b8e29 due to PhantomJS crashing in the middle of tests; I am unable to reproduce this behavior locally.) Jasmine
I’d love to migrate the whole project to Jest because it’s much faster. Unfortunately a couple of components (AutoSizer
and CellMeasurer
) depend on a more robust browser than JSDOM and currently that’s all that Jest supports.
So my proposal for now:
- Split NPM
test:unit
script into 2 child tasks:test:unit:jasmine
andtest:unit:jest
- Rename all tests that can be run in Jest from
*.test.js
to*.jest.js
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Migrating to Jest
If you'd like to try out Jest with an existing codebase, there are a number of ways to convert to Jest:
Read more >Migrating to Jest - Kent C. Dodds
I've migrated our tests from AVA to Jest in 15 minutes thanks to codemods. Setup is very easy & it's 4 times faster....
Read more >Migrating to Jest - w3resource
That is obviously not what you intend to do, this tutorial will guide you on how to migrate an existing codebase to use...
Read more >Migrating from Karma to Jest - Medium
The reason I chose to migrate from Karma to Jest is mainly Snapshot Testing. Snapshots allow updated React components to be tested against...
Read more >Migrating Ava to Jest - Code Daily
Migrating in seconds. There is almost nothing to write about on this topic because it was almost too easy. Mostly because of jest-codemods....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
On a related note, this seems to work for anyone who needs to mock out AutoSizer for snapshot testing:
Then at the top of your test file, do:
jest.mock('react-virtualized');
Update: This doesn’t seem to render out the children. I’ve created a Gist where I’ll keep working to find an ideal solution: https://gist.github.com/elevine/69a27e067032c53d64d66f4f56e978cc
No problem. That’s interesting to learn! I’m not using Mocha so that may also account for some of the difference in our impressions.
I’ve been really impressed by Jest’s mocking and snapshot functionalities. I hope to take advantage of both going forward.
Also worth pointing out that PhantomJS has been crashing for me in CI environment for weeks. Could not reproduce locally. Overall seemed very flaky. Despite its limitations, JSDom seems more robust.
Given its limitations for that matter- I’m surprised you would see faster results from Mocha+PhantomJS than from Jest+JSDom just because of the browsers alone.
Oh well. 😁 Glad you started this conversation either way. It’s interesting.
On Jan 28, 2017 1:04 PM, “Olivier Tassinari” notifications@github.com wrote: