-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(client): add integration runner #13149
Conversation
packages/client/src/__tests__/integration/integration-runner.test.ts
Outdated
Show resolved
Hide resolved
packages/client/src/__tests__/integration/integration-runner.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried limiting maxWorkers
in jest.config.js
? This is not the same thing as what you're doing in this PR (which is also an interesting idea), but it might've solved the issue.
Yes, and this does help. I have added a section in the PR description Findings that shares my stats using maxWorkers. |
const name = `${options.testType}/${options.dir}` | ||
|
||
// Errors inside this child will propagate up | ||
const child = await exec(`jest ${name} --config=${__dirname.replace(/\\\\/g, '/')}/jest.config.js --runInBand`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this process errors the entire suite will fail fast, we could catch the error and propagate it like with the logs below. WDYT?
afterAll(() => { | ||
clearTimeout(timeout) | ||
|
||
const log = logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging all at once so that it eases the load on your terminal and that they are all displayed one after the other. We might want to log errors here too...
Why
What
This PR excludes all of the tests in
./packages/client/tests/integration
from the main test suite and introduces:integration-runner.test.ts
This new file will
readDir
both thehappy/
anderrors/
tests and then perform sequential batching of n amount of tests.Between each batch, a backoff is added so that we don't completely overwhelm other components such as the database.
How can I run them?
You should not need to change anything in your workflow, however, if you especially want to run the integration test's on their own you can run:
Findings
This shows my recorded stats of the time taken to run the client test suite before, with maxWorkers, and then after this addition.
Before
cd ./packages/client && pnpm run test
Could not run - Timed out!
cd ./packages/client && pnpm run test integration
Could not run - Timed out!
Using maxWorkers
These run! However, the issue here is now that the entire test suite is running at 50% capacity when in reality we only want to limit the heavy load stuff(the integration tests).
cd ./packages/client && npx jest --maxWorkers="50%"
Pass
cd ./packages/client && npx jest integration --maxWorkers="50%"
Pass
After
cd ./packages/client && pnpm run test
Pass - 222.898 seconds faster
cd ./packages/client && pnpm run test integration
Pass - 83.634 seconds faster
Regressions
Some things we miss out on in this implementation, this is because we are now spawning Jest using
exec
. This means that the main Jest process doesn't have a full collective view of how many tests are run for example or the coverage of those files tested on inside the spawned process.