Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tests): Use node env for Jest to avoid JSDOM overhead #164

Merged
merged 1 commit into from
Jun 14, 2017

Conversation

okonet
Copy link
Contributor

@okonet okonet commented Jun 12, 2017

What kind of change does this PR introduce?
build related change

Did you add tests for your changes?

Not relevant

If relevant, did you update the documentation?

Not relevant

Summary

Jest can be configured to run in Node env only without emulating browser with JSDOM: https://facebook.github.io/jest/docs/en/configuration.html#testenvironment-string

This improves tests running speed significantly:

Before

Test Suites: 31 passed, 31 total
Tests:       1 skipped, 126 passed, 127 total
Snapshots:   110 passed, 110 total
Time:        24.577s

After

Test Suites: 31 passed, 31 total
Tests:       1 skipped, 126 passed, 127 total
Snapshots:   110 passed, 110 total
Time:        15.168s, estimated 19s

Improves the Jest running speed significantly:

Before time: 24.577s
After time: 15.168s
@okonet okonet requested a review from evenstensberg June 12, 2017 08:49
@cpojer
Copy link

cpojer commented Jun 12, 2017

I don't think this is correct. switching from jsdom to node will improve Jest's startup time by about 400ms but it should be a one time cost. Based on your output, it seems like the second run was using a cache but the first one wasn't (as indicated by "estimated xx seconds").

Can you try:

  • Run Jest once with either environment.
  • Run Jest again, this time it will use the cache.
  • Switch the environment, it will keep using the cache.

And then compare timings for #2 and #3?

@okonet
Copy link
Contributor Author

okonet commented Jun 12, 2017

@cpojer thanks for looking at it. Here are my timings:

Second run with node env:

Time:        17.528s

Switching back to defaults:

Time:        22.979s

Second run defaults:

Time:        17.542s

So it seems you're right about the caching.

@cpojer
Copy link

cpojer commented Jun 12, 2017

Still worth doing, as you are running this code in a node environment.

@evenstensberg evenstensberg requested a review from pksjce June 12, 2017 15:42
@okonet okonet merged commit 75e3540 into master Jun 14, 2017
@okonet okonet deleted the chore-jest-node-env branch June 14, 2017 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants