From 5e0b880c1adacf0057c7964081552446ea101f33 Mon Sep 17 00:00:00 2001 From: mostafanazari702 Date: Fri, 22 May 2026 21:07:13 +0200 Subject: [PATCH] fix: --fail-zero respects --delay test registration --- lib/runner.js | 1 + test/integration/options/failZero.spec.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/runner.js b/lib/runner.js index dfa5f37375..c3375899bc 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -1223,6 +1223,7 @@ Runner.prototype.run = function (fn, opts = {}) { } this.state = constants.STATE_RUNNING; if (this._opts.delay) { + this.total = this.grepTotal(this.suite); this.emit(constants.EVENT_DELAY_END); debug('run(): "delay" ended'); } diff --git a/test/integration/options/failZero.spec.js b/test/integration/options/failZero.spec.js index 16156b4b12..99478d0eff 100644 --- a/test/integration/options/failZero.spec.js +++ b/test/integration/options/failZero.spec.js @@ -1,5 +1,6 @@ "use strict"; +var path = require("node:path").posix; var helpers = require("../helpers"); var runMochaJSON = helpers.runMochaJSON; @@ -19,4 +20,22 @@ describe("--fail-zero", function () { done(); }); }); + + describe("with --delay", function () { + it("should pass when delayed tests are registered (GH-4950)", function (done) { + var fixture = path.join("options", "delay"); + runMochaJSON( + fixture, + ["--fail-zero", "--delay", "--no-forbid-only"], + function (err, res) { + if (err) { + return done(err); + } + + expect(res, "to have passed").and("to have passed test count", 1); + done(); + }, + ); + }); + }); });