From de4c8cbe45eb05c58ea2765d65a9b7bdf991d415 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Fri, 13 Feb 2026 15:24:13 +0100 Subject: [PATCH] test_runner: support runner bailout at files level --- doc/api/cli.md | 16 ++ doc/api/test.md | 36 +++++ doc/node-config-schema.json | 3 + doc/node.1 | 9 ++ lib/internal/test_runner/harness.js | 2 + lib/internal/test_runner/reporter/spec.js | 6 +- lib/internal/test_runner/reporter/utils.js | 4 + lib/internal/test_runner/runner.js | 80 ++++++++-- lib/internal/test_runner/test.js | 12 +- lib/internal/test_runner/tests_stream.js | 9 ++ lib/internal/test_runner/utils.js | 2 + src/node_options.cc | 6 + src/node_options.h | 1 + .../test-runner/bail/bail-test-1-pass.js | 12 ++ .../test-runner/bail/bail-test-2-fail.js | 11 ++ .../test-runner/bail/bail-test-3-pass.js | 10 ++ .../test-runner/bail/bail-test-4-pass.js | 6 + .../test-runner/output/bail_concurrency_1.js | 13 ++ .../output/bail_concurrency_1.snapshot | 55 +++++++ .../bail_concurrency_1_isolation_none.js | 13 ++ ...bail_concurrency_1_isolation_none.snapshot | 39 +++++ test/parallel/test-runner-bail.js | 137 ++++++++++++++++++ .../test-runner-run-bail-isolation-none.mjs | 55 +++++++ test/parallel/test-runner-run-bail.mjs | 73 ++++++++++ ...tput-bail-spec-reporter-isolation-none.mjs | 10 ++ .../test-output-bail-spec-reporter.mjs | 10 ++ 26 files changed, 617 insertions(+), 13 deletions(-) create mode 100644 test/fixtures/test-runner/bail/bail-test-1-pass.js create mode 100644 test/fixtures/test-runner/bail/bail-test-2-fail.js create mode 100644 test/fixtures/test-runner/bail/bail-test-3-pass.js create mode 100644 test/fixtures/test-runner/bail/bail-test-4-pass.js create mode 100644 test/fixtures/test-runner/output/bail_concurrency_1.js create mode 100644 test/fixtures/test-runner/output/bail_concurrency_1.snapshot create mode 100644 test/fixtures/test-runner/output/bail_concurrency_1_isolation_none.js create mode 100644 test/fixtures/test-runner/output/bail_concurrency_1_isolation_none.snapshot create mode 100644 test/parallel/test-runner-bail.js create mode 100644 test/parallel/test-runner-run-bail-isolation-none.mjs create mode 100644 test/parallel/test-runner-run-bail.mjs create mode 100644 test/test-runner/test-output-bail-spec-reporter-isolation-none.mjs create mode 100644 test/test-runner/test-output-bail-spec-reporter.mjs diff --git a/doc/api/cli.md b/doc/api/cli.md index 52e9cf6cb8615c..40a42864fba80a 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2614,6 +2614,21 @@ Starts the Node.js command line test runner. This flag cannot be combined with See the documentation on [running tests from the command line][] for more details. +### `--test-bail` + + + +> Stability: 1.0 - Early development + +Stops the test runner after the first test failure. + +Behavior depends on `--test-isolation`. +See the [test runner execution model][] section for details. + +This flag cannot be combined with `--watch`. + ### `--test-concurrency`