✅ Migrate race condition tests to Vitest#6754
Conversation
Replace the Jest subprocess runner with Vitest for snippet validation tests.
The snippets themselves remain unchanged - only the test harness is updated:
- Use vitest binary instead of jest binary
- Prepend `import { vi as jest, test, expect } from 'vitest'` (aliasing vi as jest)
- Generate a vitest.config.mjs per test directory with fast-check source alias
- Combine stdout+stderr for output assertions
- Remove unused `cwd` import
https://claude.ai/code/session_01VJVn4FasB8hokBSQsUdnCk
|
@fast-check/ava
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
|
@claude it fails with: FAIL website docs/tutorials/detect-race-conditions/snippets.spec.mjs�[2m > Playground�[2m > snippet v5�[2m > should pass on extendedExceptions
�[2m❯ docs/tutorials/detect-race-conditions/snippets.spec.mjs:�[2m89:34 �[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[21/21]⎯ �[2m Test Files 1 failed�[2m | 81 passed (82) Fix it |
|
Claude finished @dubzzz's task in 1m 17s —— View job Fixing Vitest migration for race condition detection tests
Root causeOn Windows CI, `... alias: { 'fast-check': '${fastCheckSourcePath}' } ...`The backslashes were interpreted as JS escape characters (e.g. FixReplaced the single-quoted string interpolation with |
Use JSON.stringify to properly escape backslashes in the fast-check source path when writing the Vitest config file. On Windows, path.join produces backslashes which were interpreted as escape characters in the JS string literal, causing 'Cannot find package fast-check' errors. Co-authored-by: Nicolas DUBIEN <[email protected]>
| await fs.writeFile( | ||
| vitestConfigPath, | ||
| `import { defineConfig } from 'vitest/config';\n` + | ||
| `export default defineConfig({ test: { include: ['queue.spec.mjs'] }, resolve: { alias: { 'fast-check': ${JSON.stringify(fastCheckSourcePath)} } } });`, |
There was a problem hiding this comment.
@claude why do we need the alias? Is there a way to drop the need for such alias
There was a problem hiding this comment.
Claude finished @dubzzz's task in 2m 16s —— View job
- Analyze why the alias was added
- Remove the alias and rely on standard Node module resolution
- Commit and push
Answer
The alias isn't needed. It was pointing to the source .ts file at packages/fast-check/src/fast-check.ts, but that's unnecessary because standard Node module resolution already works here:
- The temp test files live under
website/.test-artifacts/test-xxx/ - Node resolution walks up:
.test-artifacts/→website/→ findsnode_modules/fast-check website/node_modules/fast-checkis a pnpm workspace symlink topackages/fast-check/- CI unpacks the production bundles before running tests, so
lib/fast-check.jsexists
This is exactly how the original Jest setup worked — no special resolution was needed there either.
I've removed the alias and the fastCheckSourcePath variable. The Vitest config now just sets test.include — same minimal config as the old jest.config.cjs.
…lution The temp test directories are under website/.test-artifacts/, so Node module resolution walks up to website/node_modules/fast-check (workspace symlink). No alias needed — same as the original Jest approach. Co-authored-by: Nicolas DUBIEN <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6754 +/- ##
=======================================
Coverage 94.51% 94.51%
=======================================
Files 210 210
Lines 5686 5686
Branches 1500 1500
=======================================
Hits 5374 5374
Misses 299 299
Partials 13 13
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
Migrates the race condition detection tutorial test suite from Jest to Vitest. This change updates the test infrastructure to use Vitest as the test runner, which provides better ESM support and improved performance for this use case.
Changes:
jest.config.cjstovitest.config.mjswith appropriate Vitest settingsvi,test,expect) instead of Jest's--run,--no-color)fast-checkto the local sourcecwdimport fromprocessChecklist
pnpm run bumpor by following the instructions from the changeset bothttps://claude.ai/code/session_01VJVn4FasB8hokBSQsUdnCk