Skip to content

test_runner: support test order randomization#61747

Open
pmarchini wants to merge 4 commits intonodejs:mainfrom
pmarchini:test_runner/deterministic-test-randomizer
Open

test_runner: support test order randomization#61747
pmarchini wants to merge 4 commits intonodejs:mainfrom
pmarchini:test_runner/deterministic-test-randomizer

Conversation

@pmarchini
Copy link
Member

@pmarchini pmarchini commented Feb 8, 2026

This PR adds deterministic randomization to the Node.js test runner at both levels:

  • test file execution order
  • the order of tests inside each file

--test-randomize enables randomized execution, and --test-random-seed=<seed> replays the same order deterministically (and implicitly enables randomization).
When no seed is provided, one is generated and printed in the summary so runs are easy to reproduce.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Feb 8, 2026
@pmarchini pmarchini force-pushed the test_runner/deterministic-test-randomizer branch 2 times, most recently from 5556788 to e6f9a59 Compare February 8, 2026 22:20
@pmarchini pmarchini added test_runner Issues and PRs related to the test runner subsystem. semver-minor PRs that contain new features and should be released in the next minor version. labels Feb 8, 2026
@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.75%. Comparing base (ae2ffce) to head (84b6260).
⚠️ Report is 119 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #61747    +/-   ##
========================================
  Coverage   89.75%   89.75%            
========================================
  Files         674      675     +1     
  Lines      204416   204828   +412     
  Branches    39285    39352    +67     
========================================
+ Hits       183472   183851   +379     
- Misses      13227    13257    +30     
- Partials     7717     7720     +3     
Files with missing lines Coverage Δ
lib/internal/test_runner/runner.js 93.63% <100.00%> (+0.49%) ⬆️
lib/internal/test_runner/test.js 97.38% <100.00%> (+0.05%) ⬆️
lib/internal/test_runner/utils.js 65.61% <100.00%> (+3.58%) ⬆️
src/node_options.cc 76.47% <100.00%> (+0.19%) ⬆️
src/node_options.h 97.92% <100.00%> (+0.03%) ⬆️

... and 62 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pmarchini pmarchini force-pushed the test_runner/deterministic-test-randomizer branch from e6f9a59 to b3b2388 Compare February 9, 2026 08:09
@pmarchini pmarchini marked this pull request as draft February 9, 2026 08:42
@pmarchini pmarchini force-pushed the test_runner/deterministic-test-randomizer branch from b3b2388 to 08db017 Compare February 9, 2026 09:19
@pmarchini pmarchini marked this pull request as ready for review February 9, 2026 09:19
@pmarchini pmarchini force-pushed the test_runner/deterministic-test-randomizer branch from 2eeb519 to 08db017 Compare February 10, 2026 21:28
@pmarchini pmarchini force-pushed the test_runner/deterministic-test-randomizer branch from 08db017 to 4d626b6 Compare February 10, 2026 22:16
@pmarchini pmarchini requested a review from MoLow February 12, 2026 11:56
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

🙌

I see I'm late to the party. None of my comments are pressing :)

```

Using suite-style APIs such as `describe()`/`it()` or `suite()`/`test()`
still allows randomization, because sibling tests are queued together.
Copy link
Member

Choose a reason for hiding this comment

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

nit: I thiiink it should be "enqueued"? "queued" together means they wait together; enqueued together means they're added to a queue one-by-one setting up a sequence.

@@ -191,6 +198,12 @@ function getRunArgs(path, { forceExit,
if (rerunFailuresFilePath) {
ArrayPrototypePush(runArgs, `--test-rerun-failures=${rerunFailuresFilePath}`);
}
if (randomize === true) {
Copy link
Member

Choose a reason for hiding this comment

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

Related to the skip and todo discussion: should this check truthiness rather than strict?

@JakobJingleheimer
Copy link
Member

@nodejs-github-bot
Copy link
Collaborator

@JakobJingleheimer JakobJingleheimer added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants