🐛 Fix flaky worker test by improving Jest child process handling#6863
🐛 Fix flaky worker test by improving Jest child process handling#6863dubzzz wants to merge 2 commits into
Conversation
|
|
👋 It looks like the PR template was not used for this pull request. Please edit the PR description to use the template, or close this PR and open a new one that uses it. The template includes:
Thank you for your contribution! 🙏 |
@fast-check/ava
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
|
@claude extract a dedicated pr just for the ai related env thing |
|
Claude finished @dubzzz's task in 2m 25s —— View job Extracted AI env var stripping into a dedicated PR
Done! Created #6864 with just the AI agent env var stripping ( This PR (#6863) has been updated to remove the env var change — it now only contains the stdout/stderr capture, |
|
@claude if applicable to vitest tests too (in fast-check/vitest) do apply something similar for env trick for vitest running in ai workers. Before doing it confirm it's needed for vitest suites |
|
Claude finished @dubzzz's task in 3m 42s —— View job Applied AI env var stripping to vitest tests
Why it's needed: Vitest 4.x uses What was done: Added the same env var filtering to |
|
@claude add comment on top of exit flag, timeout... To explain in one line why they have to be wdded |
|
Claude finished @dubzzz's task in 2m 13s —— View job Adding explanatory comments to test options
Added inline comments in
Note: there was a rebase conflict with the concurrent env var extraction — resolved by keeping comments but without |
|
@claude move strip ai env for vitest into a dedicated pr |
|
Claude finished @dubzzz's task in 3m 28s —— View job Extracted vitest AI env var stripping into a dedicated PR
Done! Created #6865 with just the vitest AI agent env var stripping ( This PR (#6863) has been updated to remove the vitest env var change — it now only contains the Jest stdout/stderr capture, |
## Description Strip AI agent environment variables (CLAUDE_CODE, CURSOR_AGENT, etc.) from the environment passed to Jest child processes in tests. When tests run inside an AI agent environment, Jest may pick up these env vars and use AgentReporter instead of its default reporter, which strips the verbose test result markers (`PASS`/`FAIL`) that the test assertions rely on. This causes spurious test failures. Extracted from #6863. ## Checklist — _Don't delete this checklist and make sure you do the following before opening the PR_ - [x] I have a full understanding of every line in this PR — whether the code was hand-written, AI-generated, copied from external sources or produced by any other tool - [ ] I flagged the impact of my change (minor / patch / major) either by running `pnpm run bump` or by following the instructions from the changeset bot - [x] I kept this PR focused on a single concern and did not bundle unrelated changes - [x] I followed the [gitmoji](https://gitmoji.dev/) specification for the name of the PR, including the package scope (e.g. `🐛(vitest) Something...`) when the change targets a package other than `fast-check` - [x] I added relevant tests and they would have failed without my PR (when applicable) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Nicolas DUBIEN <[email protected]>
The "should fail on property blocking the main thread" test was flaky because when the Jest child process exited with an error (e.g. after killing a hung worker thread), the output could end up in stdout instead of stderr. The catch block now returns both streams combined. https://claude.ai/code/session_014MbtNcfKa6gyj8iWAdG5wp
5fab53a to
4691b3a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6863 +/- ##
=======================================
Coverage 94.86% 94.86%
=======================================
Files 209 209
Lines 5665 5665
Branches 1488 1488
=======================================
Hits 5374 5374
Misses 283 283
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
## Description Strip AI agent environment variables (CLAUDE_CODE, CURSOR_AGENT, etc.) from the environment passed to vitest child processes in tests. When tests run inside an AI agent environment, vitest may pick up these env vars and use AgentReporter instead of its default reporter, which strips the verbose test result markers (`✓`) that the test assertions rely on. This causes spurious test failures. Extracted from #6863. Mirrors the Jest equivalent in #6864. ## Checklist — _Don't delete this checklist and make sure you do the following before opening the PR_ - [x] I have a full understanding of every line in this PR — whether the code was hand-written, AI-generated, copied from external sources or produced by any other tool - [ ] I flagged the impact of my change (minor / patch / major) either by running `pnpm run bump` or by following the instructions from the changeset bot - [x] I kept this PR focused on a single concern and did not bundle unrelated changes - [x] I followed the [gitmoji](https://gitmoji.dev/) specification for the name of the PR, including the package scope (e.g. `🐛(vitest) Something...`) when the change targets a package other than `fast-check` - [x] I added relevant tests and they would have failed without my PR (when applicable) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Nicolas DUBIEN <[email protected]>
|
@claude use pr template |
|
Claude finished @dubzzz's task in 2m 11s —— View job Updating PR to use template
Updated the PR description to use the repository's PR template from |
Description
Fix the flaky "should fail on property blocking the main thread" test in
@fast-check/jestby improving how the test captures Jest child process output.The Jest child process could produce output on either stdout or stderr depending on timing. The test was only capturing stderr, which sometimes missed the expected markers. Additionally, tightened timeout thresholds and reduced setTimeout values to make assertions more reliable.
Changes:
jest.setTimeout/testTimeoutCLIfrom 3000ms to 2000ms for consistencyexpectTimeoutupper bound fromtimeout * 2totimeout * 1.5Related: #6864 (extracted AI env var stripping), #6865 (vitest equivalent)
Checklist
— Don't delete this checklist and make sure you do the following before opening the PR
pnpm run bumpor by following the instructions from the changeset bot🐛(vitest) Something...) when the change targets a package other thanfast-check