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

test: jest improvements #4650

Merged
merged 8 commits into from
Aug 5, 2022
Merged

test: jest improvements #4650

merged 8 commits into from
Aug 5, 2022

Conversation

paul-soporan
Copy link
Member

@paul-soporan paul-soporan commented Jul 20, 2022

What's the problem this PR addresses?

This PR gradually upgrades Jest, enables some new features, and tries to improve the performance of running the test suites.

It's a draft because I want to gradually see how each improvement affects things (e.g. the speedup brought by upgrading to Jest 27, then the one brought by upgrading to Jest 28, then the one by enabling shards and so on).

Closes #4676.

How did you fix it?

  • Upgrade to Jest 27
  • Upgrade to Jest 28
  • Don't specify modern timers since they're the new default
  • Fix PnP tests on Windows (some paths didn't get converted)
  • Update all Babel dependencies
  • Use shards

Abandoned ideas:

  • Caching the Jest cache, the difference is only around 30 seconds per workflow; IMO it isn't worth it due to the extra complexity
  • Transpiling the test files using ESBuild (jest-esbuild), takes around 29m on ubuntu instead of 14m
  • Using test.concurrent: It's very buggy, doesn't properly support snapshots, and our tests are currently written in a way that assumes sequential execution (setPackageWhitelist and startRegistryRecording use non-atomic global mutable state). In any case, test.concurrent doesn't seem to help that much on CI, since we already use --maxWorkers=100%, and each run call spawns a new process on a different thread. Because of this, test.concurrent is much more useful when running a single test file at a time.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@paul-soporan paul-soporan force-pushed the paul/test/jest-improvements branch 4 times, most recently from c5bd4a2 to c3b6ea9 Compare July 21, 2022 02:51
@merceyz
Copy link
Member

merceyz commented Jul 21, 2022

Since this causes some of the Babel dependencies to get updated, could you update all of them?
There are some performance improvements that might help.12

yarn up "@babel/*"
yarn up "@babel/*" -R
yarn dedupe

Footnotes

  1. https://github.com/babel/babel/blob/b58e35b6aa30a4c58da3147ae4a1fb5cef2073c9/CHANGELOG.md#running_woman-performance-2

  2. https://github.com/babel/babel/blob/b58e35b6aa30a4c58da3147ae4a1fb5cef2073c9/CHANGELOG.md#running_woman-performance

@V-for-Vasili
Copy link

Hello! Are there any plans to go forward with this? Specifically interested in Jest upgrade, as version 26.2.0 addresses significant issue with Posix find: jestjs/jest#10263

@paul-soporan
Copy link
Member Author

Yep, I'll finish this PR today, sorry for the delay!

@paul-soporan paul-soporan force-pushed the paul/test/jest-improvements branch 2 times, most recently from 86d0ece to a2e8760 Compare August 4, 2022 15:29
@paul-soporan
Copy link
Member Author

Re: #4650 (comment)

Upgraded the Babel deps, not sure whether it actually improves perf since the results are within the margin of error (both positive and negative).

@paul-soporan
Copy link
Member Author

I ended up using 2 shards for the ubuntu tests and 3 shards for the windows and macos ones since they're much slower. With these changes, all tests finish in 10 minutes at most.

@arcanis I think you have to update the protected branch settings to take into account the new check names since the old checks are still reported as and 5 expected checks .

@paul-soporan paul-soporan marked this pull request as ready for review August 4, 2022 18:20
Copy link
Member

@merceyz merceyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! 🎉

@arcanis arcanis merged commit b6273b3 into master Aug 5, 2022
@arcanis arcanis deleted the paul/test/jest-improvements branch August 5, 2022 09:00
merceyz pushed a commit that referenced this pull request Nov 21, 2023
* chore: upgrade to jest 27

* chore: upgrade to jest 28

* refactor: don't specify modern timers since they're the new default

* test: fix tests on windows

* chore: update babel

* ci: use shards

* ci: try different shard configuration

* style: tweak configuration

(cherry picked from commit b6273b3)
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.

[Bug?]: Native file crawling doesn't work with POSIX find
4 participants