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

Run single-file test in a process if we know it takes long #6599

Closed
gaearon opened this issue Jul 2, 2018 · 5 comments · Fixed by #6647
Closed

Run single-file test in a process if we know it takes long #6599

gaearon opened this issue Jul 2, 2018 · 5 comments · Fixed by #6647

Comments

@gaearon
Copy link
Contributor

gaearon commented Jul 2, 2018

🚀 Feature Proposal

We have some heavy test files in Prepack repo which can't be made faster. Each test file has ~10 tests and runs for ~10 seconds.

We lose a lot of productivity because once a test starts, it completely freezes Jest until the test has run. Even if there's a typo we need to quickly fix. And we find it helpful to focus on a single test file.

Since Jest already tracks how much time a test takes, we want it to use a separate process (instead of in-process runs) for test files that are known to be heavy. This would mean tweaking the heuristic that Jest uses to decide whether to run tests in-process or not.

@gaearon
Copy link
Contributor Author

gaearon commented Jul 2, 2018

cc @cpojer

@cpojer
Copy link
Member

cpojer commented Jul 2, 2018

Dan and I discussed this in person before filing the issue. I think it makes the most sense to run fast tests (<3s) in process and spawn a new process if we have a single slow test.

facebook-github-bot pushed a commit to facebookarchive/prepack that referenced this issue Jul 2, 2018
Summary:
Currently we have a single giant file with all tests, and a giant snapshot. This is both slow, and hard to work with and iterate on.

In this PR I will refactor our test setup.

- [x] Split it up into multiple files (gets the test running from 45s to 27s)
- [x] Run Prettier on test files
- [x] Split tests further for better performance
- [x] Make it possible to run one test file
- [x] Fix the issue with double test re-runs in watch mode on changes in the test file
- [x] Refactor error handling
- [x] Run Prettier on fixtures
- [x] Add a fast mode with `yarn test-react-fast <Filename>`
- [x] Fix double reruns on failure

Potential followups:
- [x] Figure out why test interruption broke (need jestjs/jest#6599 and jestjs/jest#6598 fixed)
- [x] Revisit weird things like `this['React']` assignment with a funny comment in every test
Closes #2187

Differential Revision: D8713639

Pulled By: gaearon

fbshipit-source-id: 5edbfa4e61610ecafff17c0e5e7f84d44cd51168
@rogeliog
Copy link
Contributor

rogeliog commented Jul 5, 2018

I like this idea!

@gaearon
Copy link
Contributor Author

gaearon commented Jul 5, 2018

cc @mjesun who had thoughts on this

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants