Skip to content

fix(sequence): stabilize file shuffle (fix #11340) - #11345

Closed
EnginKARATAS wants to merge 2 commits into
vitest-dev:mainfrom
EnginKARATAS:fix/11340-deterministic-file-order
Closed

EnginKARATAS wants to merge 2 commits into
vitest-dev:mainfrom
EnginKARATAS:fix/11340-deterministic-file-order

Conversation

@EnginKARATAS

@EnginKARATAS EnginKARATAS commented Sep 24, 2026 •

Copy link
Copy Markdown

PR title

fix(sequence): stabilize file shuffle (fix #11340)

PR body

Description

Resolves #11340

Sort file specifications by module ID, with task ID as a tie breaker, before applying the seeded shuffle. The same files and seed now produce the same order even when file discovery order differs.

The new regression test failed on upstream main and passes with this change. The existing fixed-seed expectation was updated for the canonical input order.

AI assistance: Codex prepared the code and this draft. Please review the change yourself before opening the PR, as Vitest requires a real person to submit it.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • This PR references an existing issue where the bug is described.
  • The regression test fails without the fix and passes with it.
  • No pnpm-lock.yaml changes were made.
  • Check the GitHub option to allow edits by maintainers when opening the PR.

Tests

  • pnpm build
  • pnpm -C test/unit test:threads test/sequencers.test.ts --run (11 passed)
  • pnpm -C test/e2e test test/config/sequence-shuffle.test.ts --run (15 passed)
  • pnpm typecheck
  • pnpm lint
  • pnpm test:ci passed. It was run, but stopped in the coverage suite: three on-failure.test.ts snapshots contain an extra coverage summary on this Windows setup. The same v8 snapshot failure was reproduced in a separate, unmodified upstream/main checkout. The coverage test configuration does not enable file shuffling.

Documentation

  • No new functionality or configuration option was introduced; no documentation change is needed.

Changesets

  • The PR title uses the required fix prefix and describes the change.

@netlify

netlify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 51adcb5
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6ab4e56dbeed92000874ab08
😎 Deploy Preview https://deploy-preview-11345--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@EnginKARATAS

Copy link
Copy Markdown
Author

hello

public async sort(files: TestSpecification[]): Promise<TestSpecification[]> {
const { sequence } = this.ctx.config

files.sort((a, b) => a.moduleId.localeCompare(b.moduleId) || a.taskId.localeCompare(b.taskId))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

localeCompare sorts by host locale, so Czech puts chunk after config and Danish puts aa last. With aa, chunk and config test files, seed 101 shuffles into three different orders under en_US, cs_CZ and da_DK.

@sheremet-va

Copy link
Copy Markdown
Member

#11350 has a more robust implementation

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sequence.seed does not reproduce shuffled file order

3 participants