From 016837fdda04b0b8c84ead61db6f37dbac25ee5f Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Sun, 25 Jan 2026 23:45:13 -0600 Subject: [PATCH 1/4] test: fix line numbers in stack traces --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 25511ccffa..5553f24346 100644 --- a/package.json +++ b/package.json @@ -72,8 +72,8 @@ "test-browser": "run-s clean build test-browser:*", "test-coverage-clean": "rimraf .nyc_output coverage", "test-coverage-generate": "nyc report --reporter=lcov --reporter=text", - "test-node-run-only": "nyc --no-clean --reporter=json node bin/mocha.js --no-forbid-only", - "test-node-run": "nyc --no-clean --reporter=json node bin/mocha.js --forbid-only", + "test-node-run-only": "NODE_OPTIONS=--enable-source-maps nyc --no-clean --reporter=json node bin/mocha.js --no-forbid-only", + "test-node-run": "NODE_OPTIONS=--enable-source-maps nyc --no-clean --reporter=json node bin/mocha.js --forbid-only", "test-node:integration": "run-s clean build && npm run -s test-node-run -- --parallel --timeout 10000 --slow 3750 \"test/integration/**/*.spec.js\"", "test-node:integration:watch": "run-s clean build && npm run -s test-node-run -- --parallel --timeout 10000 --slow 3750 \"test/integration/options/watch.spec.js\"", "test-node:interfaces:bdd": "npm run -s test-node-run -- --ui bdd test/interfaces/bdd.spec", From b6e4cc6ad3453a422e725f1a5f0b18fe67f2f0ee Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 28 Jan 2026 23:10:18 -0600 Subject: [PATCH 2/4] chore: use cross-env to set NODE_OPTIONS in test scripts to make it work on windows --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16ec344d5c..36b0cb34c3 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,8 @@ "test-browser": "run-s clean build test-browser:*", "test-coverage-clean": "rimraf .nyc_output coverage", "test-coverage-generate": "nyc report --reporter=lcov --reporter=text", - "test-node-run-only": "NODE_OPTIONS=--enable-source-maps nyc --no-clean --reporter=json node bin/mocha.js --no-forbid-only", - "test-node-run": "NODE_OPTIONS=--enable-source-maps nyc --no-clean --reporter=json node bin/mocha.js --forbid-only", + "test-node-run-only": "cross-env NODE_OPTIONS=--enable-source-maps nyc --no-clean --reporter=json node bin/mocha.js --no-forbid-only", + "test-node-run": "cross-env NODE_OPTIONS=--enable-source-maps nyc --no-clean --reporter=json node bin/mocha.js --forbid-only", "test-node:integration": "run-s clean build && npm run -s test-node-run -- --parallel --timeout 10000 --slow 3750 \"test/integration/**/*.spec.js\"", "test-node:integration:watch": "run-s clean build && npm run -s test-node-run -- --parallel --timeout 10000 --slow 3750 \"test/integration/options/watch.spec.js\"", "test-node:interfaces:bdd": "npm run -s test-node-run -- --ui bdd test/interfaces/bdd.spec", From 8d79bf7fc8fef6a4d5ec2caa974a70059011bfc5 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Fri, 30 Jan 2026 15:23:02 -0600 Subject: [PATCH 3/4] test: add test for fix to #5663 NOTE: the nyc config to unexclude failing-sync.fixture.js from instrumentation is essential, without it the test would fail to catch any issues with stack traces. --- .nycrc | 3 ++- test/integration/repo-tooling.spec.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/integration/repo-tooling.spec.js diff --git a/.nycrc b/.nycrc index f5da62b6c3..6f744c94b7 100644 --- a/.nycrc +++ b/.nycrc @@ -17,6 +17,7 @@ "package-lock.json", "**/package-lock.json", "node_modules/**", - "scripts/**" + "scripts/**", + "!test/integration/fixtures/failing-sync.fixture.js" ] } diff --git a/test/integration/repo-tooling.spec.js b/test/integration/repo-tooling.spec.js new file mode 100644 index 0000000000..eeb28db252 --- /dev/null +++ b/test/integration/repo-tooling.spec.js @@ -0,0 +1,16 @@ +"use strict"; + +const { runMochaJSONAsync } = require("./helpers"); + +describe("repo tooling", function () { + it("issue-5663: line numbers are wrong in stack traces when running mocha self tests", async function () { + const output = await runMochaJSONAsync("failing-sync.fixture.js"); + expect( + output.failures[0].err.stack, + "to contain", + // this file needs to be un-excluded from nyc instrumentation, or else this test would fail to catch any + // issues with nyc instrumentation affecting stack traces. + "failing-sync.fixture.js:7", + ); + }); +}); From 4855c9c891849013e38485e97fa9c508dce9fe61 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 6 Apr 2026 19:40:58 -0500 Subject: [PATCH 4/4] chore: create separate fixture for test --- .nycrc | 2 +- test/integration/fixtures/stack-trace.fixture.js | 9 +++++++++ test/integration/repo-tooling.spec.js | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 test/integration/fixtures/stack-trace.fixture.js diff --git a/.nycrc b/.nycrc index 6f744c94b7..4ada3bab1b 100644 --- a/.nycrc +++ b/.nycrc @@ -18,6 +18,6 @@ "**/package-lock.json", "node_modules/**", "scripts/**", - "!test/integration/fixtures/failing-sync.fixture.js" + "!test/integration/fixtures/stack-trace.fixture.js" ] } diff --git a/test/integration/fixtures/stack-trace.fixture.js b/test/integration/fixtures/stack-trace.fixture.js new file mode 100644 index 0000000000..f81f9653a7 --- /dev/null +++ b/test/integration/fixtures/stack-trace.fixture.js @@ -0,0 +1,9 @@ +'use strict'; + +var assert = require('assert'); + +describe('a suite', function() { + it('should succeed', function() { + assert(false); + }); +}); diff --git a/test/integration/repo-tooling.spec.js b/test/integration/repo-tooling.spec.js index eeb28db252..f85adf24b5 100644 --- a/test/integration/repo-tooling.spec.js +++ b/test/integration/repo-tooling.spec.js @@ -4,13 +4,13 @@ const { runMochaJSONAsync } = require("./helpers"); describe("repo tooling", function () { it("issue-5663: line numbers are wrong in stack traces when running mocha self tests", async function () { - const output = await runMochaJSONAsync("failing-sync.fixture.js"); + const output = await runMochaJSONAsync("stack-trace.fixture.js"); expect( output.failures[0].err.stack, "to contain", // this file needs to be un-excluded from nyc instrumentation, or else this test would fail to catch any // issues with nyc instrumentation affecting stack traces. - "failing-sync.fixture.js:7", + "stack-trace.fixture.js:7", ); }); });