question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 and test:unit:jest
  • Rename all tests that can be run in Jest from *.test.js to *.jest.js

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
elevinecommented, Jan 20, 2017

On a related note, this seems to work for anyone who needs to mock out AutoSizer for snapshot testing:

// __mocks__/react-virtualized.js
import React from 'react';

const reactVirtualized = jest.genMockFromModule('react-virtualized');

const MockAutoSizer = () => {
  return <div />;
};

reactVirtualized.AutoSizer = MockAutoSizer;

module.exports = reactVirtualized;

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

1reaction
bvaughncommented, Jan 28, 2017

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:

I’d love to learn more about

We have around 1800+ tests, we have tried to migrate to jest, but that was way too slow. We reverted to our Mocha + Karma + PhantomJS test suite.

Iterating on tests (running in watch mode) was.

I guess that’s what I was looking for! We haven’t looked at the iterating response time. That need more investigation from my part. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bvaughn/react-virtualized/issues/539#issuecomment-275874551, or mute the thread https://github.com/notifications/unsubscribe-auth/AABznXTzSvMTfwlnvOIx98-fI5wroIfqks5rW61kgaJpZM4Lj-Jm .

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found