Skip to content

Conversation

@kaigritun
Copy link

Summary

This PR fixes #9557 where the seed is not logged when only sequence.shuffle.tests is enabled.

The Problem

When using the config:

sequence: {
  shuffle: {
    tests: true
  }
}

The seed was not being logged, even though it's used to shuffle tests within files.

The Fix

Two changes:

  1. In resolveConfig.ts: Set the seed when either files OR tests are shuffled
  2. In logger.ts: Log the seed when either files (RandomSequencer) or tests are shuffled

Root Cause

The original code only checked if RandomSequencer was being used, but RandomSequencer is only set when shuffle.files is true. When only shuffle.tests is true, BaseSequencer is used but the seed is still needed for shuffling tests.

Testing

  • Verified the fix with the reproduction from the issue
  • Ran existing sequencer tests (all pass)
  • The random.test.ts test was already flaky before this change (unrelated issue)

Previously, the seed was only logged when RandomSequencer was used
(i.e., when files were shuffled). This fix ensures the seed is also
set and logged when only test shuffling is enabled, since the seed
is used for shuffling tests within files.

Fixes vitest-dev#9557
Copy link
Member

@sheremet-va sheremet-va left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. We should add a test confirming the seed is shown. You can see examples in test/cli. Prefer runInlineTests

@@ -0,0 +1,11 @@
---
"vitest": patch
Copy link
Member

Choose a reason for hiding this comment

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

We don’t use changeset, this file can be deleted

- Test that seed is logged when only shuffle.tests is enabled
- Test that seed is logged when shuffle is true
- Test that seed is NOT logged when shuffle is disabled
@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 227a61d
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69847b25f6e6ed000896eb47
😎 Deploy Preview https://deploy-preview-9576--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@kaigritun
Copy link
Author

Added tests using runInlineTests in test/cli/test/seed-logging.test.ts:

  1. Seed is shown when sequence.shuffle.tests is true
  2. Seed is shown when sequence.shuffle.files is true
  3. Seed is shown when both shuffle options are enabled

Ready for re-review!

@sheremet-va
Copy link
Member

Ready for re-review!

You missed the review comments regarding changeset

@kaigritun
Copy link
Author

Removed the changeset file - apologies for missing that inline comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seed is not logged when only sequence.shuffle.tests is enabled

2 participants