Skip to content

fix: make file shuffling deterministic - #11350

Closed
maricastroc wants to merge 1 commit into
vitest-dev:mainfrom
maricastroc:fix/deterministic-file-shuffle
Closed

maricastroc wants to merge 1 commit into
vitest-dev:mainfrom
maricastroc:fix/deterministic-file-shuffle

Conversation

@maricastroc

Copy link
Copy Markdown

Description

RandomSequencer shuffled test specifications in discovery order. Since discovery order can vary between runs, the same sequence.seed could produce different file orders.

This change canonicalizes specifications by project name, module ID, and pool before shuffling, making the resulting order reproducible for the same set of specifications and seed.

Module ID alone is not sufficient because the same file can belong to multiple projects or exist as both a regular test and a typecheck specification.

The regression test verifies that different discovery orders produce the same result for the same seed, while different seeds still produce different orders.

An existing seed may produce a different order after upgrading because the input is now canonicalized before shuffling.

AI assistance: Claude was used during investigation and implementation.

Resolves #11340

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

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@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 f7f2525
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6ab51d9482ab8a0008d8127e
😎 Deploy Preview https://deploy-preview-11350--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.


return shuffle(files, sequence.seed)
const sorted = [...files].sort((a, b) =>
compare(a.project.name, b.project.name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a one line comment why we need to sort by multiple parameters? You explain in the PR description, but that knowledge will be lost

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Hello @maricastroc. Thank you for taking the time to contribute!

Unfortunately, the team accepts pull requests only from maintainers and approved contributors, so this pull request was closed automatically. We are sorry about that, it is not a judgement of your work. The number of pull requests grew beyond what the team can review, and this policy gives maintainers the space to triage and prioritize issues at their own pace.

Please keep the discussion in #11340. Your changes are not lost: a maintainer can reopen this pull request if the team decides to go forward with it. See our pull request policy for more context.

@github-actions github-actions Bot closed this Oct 5, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 20, 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

2 participants