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 53 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
this.pendingSubtests = [];
this.readySubtests = new SafeMap();
this.unfinishedSubtests = new SafeSet();
this.subtestsPromise = null;
this.subtests = [];
this.nextReportOrder = 1;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm still not 100% sure about this approach...I'm still thinking about a less invasive solution

@pmarchini pmarchini requested a review from MoLow February 12, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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.

4 participants