From 228897f6f6ff3ef888b0431aa3b75f8193a58157 Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Mon, 18 May 2026 12:12:26 -0700 Subject: [PATCH 1/8] test(NODE-7493): enable source maps for accurate unit test debugging Pass --enable-source-maps to Node for all mocha configs so V8 resolves inline source maps emitted by ts-node, making the debugger show correct TypeScript file/line locations. Also add sourceMap: true to test/tsconfig.json and ensure bundled test runs reset test/mongodb.ts so stale VM-context state does not affect subsequent debug sessions. --- .mocharc.js | 5 ++- package.json | 4 +- test/manual/mocharc.js | 5 ++- test/mocha_lambda.js | 5 ++- test/mocha_mongodb.js | 5 ++- test/tsconfig.json | 3 +- test/unit/sourcemap_demo.test.ts | 74 ++++++++++++++++++++++++++++++++ 7 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 test/unit/sourcemap_demo.test.ts diff --git a/.mocharc.js b/.mocharc.js index 13d28e27c2f..aa6841b1128 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -18,5 +18,8 @@ module.exports = { reporter: 'test/tools/reporter/mongodb_reporter.js', sort: true, color: true, - 'node-option': Number(major) >= 23 ? ['no-experimental-strip-types'] : undefined + 'node-option': + Number(major) >= 23 + ? ['enable-source-maps', 'no-experimental-strip-types'] + : ['enable-source-maps'] }; diff --git a/package.json b/package.json index 290e0e8c706..f2a338bf4fd 100644 --- a/package.json +++ b/package.json @@ -141,9 +141,9 @@ "check:dts": "npm run build:bundle && node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", "check:search-indexes": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration", - "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test", + "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test; npm run build:runtime-barrel", "check:unit": "npm run build:bundle && nyc mocha test/unit", - "check:unit-bundled": "MONGODB_BUNDLED=true npm run check:unit", + "check:unit-bundled": "MONGODB_BUNDLED=true npm run check:unit; npm run build:runtime-barrel", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", "check:drivers-atlas-testing": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", diff --git a/test/manual/mocharc.js b/test/manual/mocharc.js index 431bbf9a343..b948cb322a9 100644 --- a/test/manual/mocharc.js +++ b/test/manual/mocharc.js @@ -14,5 +14,8 @@ module.exports = { failZero: true, color: true, timeout: 10000, - 'node-option': Number(major) >= 23 ? ['no-experimental-strip-types'] : undefined + 'node-option': + Number(major) >= 23 + ? ['enable-source-maps', 'no-experimental-strip-types'] + : ['enable-source-maps'] }; diff --git a/test/mocha_lambda.js b/test/mocha_lambda.js index 962ab8a344b..9a87d2a2187 100644 --- a/test/mocha_lambda.js +++ b/test/mocha_lambda.js @@ -17,5 +17,8 @@ module.exports = { reporter: 'test/tools/reporter/mongodb_reporter.js', sort: true, color: true, - 'node-option': Number(major) >= 23 ? ['no-experimental-strip-types'] : undefined + 'node-option': + Number(major) >= 23 + ? ['enable-source-maps', 'no-experimental-strip-types'] + : ['enable-source-maps'] }; diff --git a/test/mocha_mongodb.js b/test/mocha_mongodb.js index d048520fea6..26bbca90479 100644 --- a/test/mocha_mongodb.js +++ b/test/mocha_mongodb.js @@ -31,5 +31,8 @@ module.exports = { 'test/integration/node-specific/examples/transactions.test.js', 'test/integration/node-specific/examples/versioned_api.js' ], - 'node-option': Number(major) >= 23 ? ['no-experimental-strip-types'] : undefined + 'node-option': + Number(major) >= 23 + ? ['enable-source-maps', 'no-experimental-strip-types'] + : ['enable-source-maps'] }; diff --git a/test/tsconfig.json b/test/tsconfig.json index 25dc395eec4..9750969223a 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "strict": false, "allowJs": true, - "checkJs": false + "checkJs": false, + "sourceMap": true }, "include": [ "../node_modules/@types/mocha/index.d.ts", diff --git a/test/unit/sourcemap_demo.test.ts b/test/unit/sourcemap_demo.test.ts new file mode 100644 index 00000000000..acbcae43c4e --- /dev/null +++ b/test/unit/sourcemap_demo.test.ts @@ -0,0 +1,74 @@ +// These import-type lines are completely erased by the TypeScript compiler +// (no blank-line placeholder is left behind), so the compiled JS has fewer +// lines than this source file. That shifts every subsequent line upward in +// the JS output. +import type { Document as _Doc } from 'bson'; +import { expect } from 'chai'; + +import type { + AbstractCursor as _AbC, + AggregationCursor as _AC, + ChangeStream as _CS, + ClientSession as _Sess, + Collection as _Col, + Db as _Db, + FindCursor as _FC, + GridFSBucket as _GB, + MongoClient as _MC +} from '../../mongodb'; + +// ─── This Error is created at line 31 in the TypeScript source. ─────────── +// The twelve `import type` lines above are erased without replacement, so +// in the compiled JS this falls on line 31 − 12 = line 19. +// +// source-map-support patches Error.prepareStackTrace so `error.stack` +// already shows the correct TS line. The demo below DISABLES that patch +// temporarily so we can see what V8 reports natively. +// +// OLD commit (no --enable-source-maps): V8 says line 19 ← WRONG +// NEW commit ( --enable-source-maps): V8 says line 31 ← correct +const TS_SOURCE_LINE = 31; // must match the line below +const errorAtKnownLine = new Error('source-map probe'); // ← line 31 + +/** + * Capture a raw V8 stack frame by temporarily removing + * source-map-support's prepareStackTrace override so we see exactly what + * V8 reports — with or without its own source-map awareness. + */ +function rawV8FrameOf(err: Error): { + file: string | null; + line: number | null; + col: number | null; +} { + const saved = Error.prepareStackTrace; + // Null → V8 uses its built-in formatter (honours --enable-source-maps). + Error.prepareStackTrace = undefined as unknown as typeof Error.prepareStackTrace; + const raw = err.stack ?? ''; // triggers V8 formatting with no hook + Error.prepareStackTrace = saved; + + // First "at …" line: " at Object. (/abs/path/file.ts:LINE:COL)" + const match = raw.split('\n')[1]?.match(/\((.+):(\d+):(\d+)\)$/); + if (!match) return { file: null, line: null, col: null }; + return { file: match[1], line: Number(match[2]), col: Number(match[3]) }; +} + +describe('Source map verification (NODE-7493)', function () { + it('V8 native stack frame reports correct TypeScript line number', function () { + const frame = rawV8FrameOf(errorAtKnownLine); + + console.log('\n ── raw V8 frame (prepareStackTrace bypassed) ──'); + console.log(` file : ${frame.file}`); + console.log(` line : ${frame.line} (TypeScript source line is ${TS_SOURCE_LINE})`); + console.log(` col : ${frame.col}`); + console.log( + ` ${frame.line === TS_SOURCE_LINE ? '✔ line matches TS source' : `✘ line ${frame.line} ≠ TS source line ${TS_SOURCE_LINE} — source maps not applied by V8`}` + ); + + expect(frame.line).to.equal( + TS_SOURCE_LINE, + `V8 reported line ${frame.line} but TypeScript source line is ${TS_SOURCE_LINE}. ` + + `This means --enable-source-maps is absent and V8 is reading the compiled-JS ` + + `line number instead of the original TypeScript line.` + ); + }); +}); From 340248e4baa0d634b640c18e6f333b4ab13dc68a Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Wed, 3 Jun 2026 12:00:32 -0700 Subject: [PATCH 2/8] test(NODE-7493): enable source maps for accurate unit test debugging --- .mocharc.js | 1 - package-lock.json | 19 ------------------- package.json | 3 +-- test/mocha_mongodb.js | 1 - test/tools/runner/hooks/configuration.ts | 5 ----- test/unit/sourcemap_demo.test.ts | 11 ++++++----- 6 files changed, 7 insertions(+), 33 deletions(-) diff --git a/.mocharc.js b/.mocharc.js index aa6841b1128..4177a964cbc 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -5,7 +5,6 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ - 'source-map-support/register', 'ts-node/register', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts', diff --git a/package-lock.json b/package-lock.json index d584873227e..35ae0cbcdf1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,7 +59,6 @@ "sinon-chai": "^3.7.0", "snappy": "^7.3.2", "socks": "^2.8.7", - "source-map-support": "^0.5.21", "ts-node": "^10.9.2", "tsd": "^0.33.0", "typescript": "5.8.3", @@ -4403,13 +4402,6 @@ "ieee754": "^1.1.13" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -9480,17 +9472,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", diff --git a/package.json b/package.json index f2a338bf4fd..ae05f26c7fb 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,6 @@ "sinon-chai": "^3.7.0", "snappy": "^7.3.2", "socks": "^2.8.7", - "source-map-support": "^0.5.21", "ts-node": "^10.9.2", "tsd": "^0.33.0", "typescript": "5.8.3", @@ -160,7 +159,7 @@ "build:bundle": "npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel", "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", - "bundle:types": "npx tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --declarationDir test/tools/runner/bundle/types", + "bundle:types": "node ./node_modules/typescript/bin/tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --declarationDir test/tools/runner/bundle/types", "fix:eslint": "npm run check:eslint -- --fix", "prepare": "node etc/prepare.js", "preview:docs": "ts-node etc/docs/preview.ts", diff --git a/test/mocha_mongodb.js b/test/mocha_mongodb.js index 26bbca90479..afbf8224571 100644 --- a/test/mocha_mongodb.js +++ b/test/mocha_mongodb.js @@ -6,7 +6,6 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ - 'source-map-support/register', 'ts-node/register', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts', diff --git a/test/tools/runner/hooks/configuration.ts b/test/tools/runner/hooks/configuration.ts index 0220d81fb9b..db6a50344b2 100644 --- a/test/tools/runner/hooks/configuration.ts +++ b/test/tools/runner/hooks/configuration.ts @@ -1,10 +1,5 @@ /* eslint-disable simple-import-sort/imports */ -// eslint-disable-next-line @typescript-eslint/no-require-imports -require('source-map-support').install({ - hookRequire: true -}); - import * as process from 'process'; import * as os from 'os'; diff --git a/test/unit/sourcemap_demo.test.ts b/test/unit/sourcemap_demo.test.ts index acbcae43c4e..f2d8982d704 100644 --- a/test/unit/sourcemap_demo.test.ts +++ b/test/unit/sourcemap_demo.test.ts @@ -21,9 +21,9 @@ import type { // The twelve `import type` lines above are erased without replacement, so // in the compiled JS this falls on line 31 − 12 = line 19. // -// source-map-support patches Error.prepareStackTrace so `error.stack` -// already shows the correct TS line. The demo below DISABLES that patch -// temporarily so we can see what V8 reports natively. +// ts-node's bundled `@cspotcode/source-map-support` patches +// Error.prepareStackTrace so `error.stack` already shows the correct TS +// line. The demo below DISABLES that patch to see what V8 reports natively. // // OLD commit (no --enable-source-maps): V8 says line 19 ← WRONG // NEW commit ( --enable-source-maps): V8 says line 31 ← correct @@ -32,8 +32,9 @@ const errorAtKnownLine = new Error('source-map probe'); // ← line 31 /** * Capture a raw V8 stack frame by temporarily removing - * source-map-support's prepareStackTrace override so we see exactly what - * V8 reports — with or without its own source-map awareness. + * `@cspotcode/source-map-support`'s prepareStackTrace override (installed + * by ts-node) so we see exactly what V8 reports — with or without its own + * source-map awareness. */ function rawV8FrameOf(err: Error): { file: string | null; From d5fbddd9361b3a95424c008c62d605f5a39cfa0a Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Wed, 3 Jun 2026 12:51:06 -0700 Subject: [PATCH 3/8] Rename source map test --- .../{sourcemap_demo.test.ts => source_map.test.ts} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename test/unit/{sourcemap_demo.test.ts => source_map.test.ts} (88%) diff --git a/test/unit/sourcemap_demo.test.ts b/test/unit/source_map.test.ts similarity index 88% rename from test/unit/sourcemap_demo.test.ts rename to test/unit/source_map.test.ts index f2d8982d704..d3908c31ec6 100644 --- a/test/unit/sourcemap_demo.test.ts +++ b/test/unit/source_map.test.ts @@ -23,7 +23,7 @@ import type { // // ts-node's bundled `@cspotcode/source-map-support` patches // Error.prepareStackTrace so `error.stack` already shows the correct TS -// line. The demo below DISABLES that patch to see what V8 reports natively. +// line. We DISABLE that patch to see what V8 reports natively. // // OLD commit (no --enable-source-maps): V8 says line 19 ← WRONG // NEW commit ( --enable-source-maps): V8 says line 31 ← correct @@ -53,8 +53,8 @@ function rawV8FrameOf(err: Error): { return { file: match[1], line: Number(match[2]), col: Number(match[3]) }; } -describe('Source map verification (NODE-7493)', function () { - it('V8 native stack frame reports correct TypeScript line number', function () { +describe('Source maps', function () { + it('report the collect line number when enabled', function () { const frame = rawV8FrameOf(errorAtKnownLine); console.log('\n ── raw V8 frame (prepareStackTrace bypassed) ──'); @@ -68,8 +68,8 @@ describe('Source map verification (NODE-7493)', function () { expect(frame.line).to.equal( TS_SOURCE_LINE, `V8 reported line ${frame.line} but TypeScript source line is ${TS_SOURCE_LINE}. ` + - `This means --enable-source-maps is absent and V8 is reading the compiled-JS ` + - `line number instead of the original TypeScript line.` + `This means --enable-source-maps is absent and V8 is reading the compiled-JS ` + + `line number instead of the original TypeScript line.` ); }); }); From 130a107f14f8b300640ba6ce8a11e53d3352d7ae Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Thu, 4 Jun 2026 08:15:18 -0700 Subject: [PATCH 4/8] Remove building the barrel from check:unit-bundled and check:test-bundled --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae05f26c7fb..a30b8e1d292 100644 --- a/package.json +++ b/package.json @@ -140,9 +140,9 @@ "check:dts": "npm run build:bundle && node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", "check:search-indexes": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration", - "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test; npm run build:runtime-barrel", + "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test", "check:unit": "npm run build:bundle && nyc mocha test/unit", - "check:unit-bundled": "MONGODB_BUNDLED=true npm run check:unit; npm run build:runtime-barrel", + "check:unit-bundled": "MONGODB_BUNDLED=true npm run check:unit", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", "check:drivers-atlas-testing": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", From 54b538cf463ad1933e143e06bf56f43914a89190 Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Thu, 4 Jun 2026 08:16:59 -0700 Subject: [PATCH 5/8] fix: typo --- test/unit/source_map.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/source_map.test.ts b/test/unit/source_map.test.ts index d3908c31ec6..c49d326b7e7 100644 --- a/test/unit/source_map.test.ts +++ b/test/unit/source_map.test.ts @@ -54,7 +54,7 @@ function rawV8FrameOf(err: Error): { } describe('Source maps', function () { - it('report the collect line number when enabled', function () { + it('report the correct line number when enabled', function () { const frame = rawV8FrameOf(errorAtKnownLine); console.log('\n ── raw V8 frame (prepareStackTrace bypassed) ──'); From d017df91fd2fb462238dc520a1b85b7f06b0111d Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Thu, 4 Jun 2026 08:26:15 -0700 Subject: [PATCH 6/8] Guard console logs with VERBOSE variable Use `VERBOSE=1 npm run check:unit -- -g "Source maps"` to run --- test/unit/source_map.test.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/unit/source_map.test.ts b/test/unit/source_map.test.ts index c49d326b7e7..acae1aa7d28 100644 --- a/test/unit/source_map.test.ts +++ b/test/unit/source_map.test.ts @@ -57,14 +57,15 @@ describe('Source maps', function () { it('report the correct line number when enabled', function () { const frame = rawV8FrameOf(errorAtKnownLine); - console.log('\n ── raw V8 frame (prepareStackTrace bypassed) ──'); - console.log(` file : ${frame.file}`); - console.log(` line : ${frame.line} (TypeScript source line is ${TS_SOURCE_LINE})`); - console.log(` col : ${frame.col}`); - console.log( - ` ${frame.line === TS_SOURCE_LINE ? '✔ line matches TS source' : `✘ line ${frame.line} ≠ TS source line ${TS_SOURCE_LINE} — source maps not applied by V8`}` - ); - + if (process.env.VERBOSE) { + console.error('\n ── raw V8 frame (prepareStackTrace bypassed) ──'); + console.error(` file : ${frame.file}`); + console.error(` line : ${frame.line} (TypeScript source line is ${TS_SOURCE_LINE})`); + console.error(` col : ${frame.col}`); + console.error( + ` ${frame.line === TS_SOURCE_LINE ? '✔ line matches TS source' : `✘ line ${frame.line} ≠ TS source line ${TS_SOURCE_LINE} — source maps not applied by V8`}` + ); + } expect(frame.line).to.equal( TS_SOURCE_LINE, `V8 reported line ${frame.line} but TypeScript source line is ${TS_SOURCE_LINE}. ` + From f0ab6854a82af1574e730a4d2c55391698f413e8 Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Fri, 5 Jun 2026 14:15:26 -0700 Subject: [PATCH 7/8] wip --- .mocharc.js | 1 + package-lock.json | 20 +++++++++++++++++++- package.json | 1 + test/manual/mocharc.js | 1 + test/mocha_mongodb.js | 1 + test/tools/runner/hooks/configuration.ts | 5 +++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.mocharc.js b/.mocharc.js index 4177a964cbc..aa6841b1128 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -5,6 +5,7 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ + 'source-map-support/register', 'ts-node/register', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts', diff --git a/package-lock.json b/package-lock.json index 35ae0cbcdf1..3dbae71a69b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,6 @@ "@typescript-eslint/eslint-plugin": "^8.46.3", "@typescript-eslint/parser": "^8.31.1", "aws4": "^1.13.2", - "baseline-browser-mapping": "^2.10.0", "chai": "^4.4.1", "chai-subset": "^1.6.0", "chalk": "^4.1.2", @@ -59,6 +58,7 @@ "sinon-chai": "^3.7.0", "snappy": "^7.3.2", "socks": "^2.8.7", + "source-map-support": "^0.5.21", "ts-node": "^10.9.2", "tsd": "^0.33.0", "typescript": "5.8.3", @@ -4402,6 +4402,13 @@ "ieee754": "^1.1.13" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -9472,6 +9479,17 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", diff --git a/package.json b/package.json index a30b8e1d292..dd6f7558d69 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "sinon-chai": "^3.7.0", "snappy": "^7.3.2", "socks": "^2.8.7", + "source-map-support": "^0.5.21", "ts-node": "^10.9.2", "tsd": "^0.33.0", "typescript": "5.8.3", diff --git a/test/manual/mocharc.js b/test/manual/mocharc.js index b948cb322a9..24e435b353b 100644 --- a/test/manual/mocharc.js +++ b/test/manual/mocharc.js @@ -6,6 +6,7 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ + 'source-map-support/register', 'ts-node/register', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts' diff --git a/test/mocha_mongodb.js b/test/mocha_mongodb.js index afbf8224571..26bbca90479 100644 --- a/test/mocha_mongodb.js +++ b/test/mocha_mongodb.js @@ -6,6 +6,7 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ + 'source-map-support/register', 'ts-node/register', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts', diff --git a/test/tools/runner/hooks/configuration.ts b/test/tools/runner/hooks/configuration.ts index db6a50344b2..0220d81fb9b 100644 --- a/test/tools/runner/hooks/configuration.ts +++ b/test/tools/runner/hooks/configuration.ts @@ -1,5 +1,10 @@ /* eslint-disable simple-import-sort/imports */ +// eslint-disable-next-line @typescript-eslint/no-require-imports +require('source-map-support').install({ + hookRequire: true +}); + import * as process from 'process'; import * as os from 'os'; From a1be2a88ec100528a9737560ebdfb836ee3f03b0 Mon Sep 17 00:00:00 2001 From: Sean Milligan Date: Fri, 5 Jun 2026 14:41:22 -0700 Subject: [PATCH 8/8] wip --- .mocharc.js | 2 +- test/manual/mocharc.js | 2 +- test/mocha_mongodb.js | 2 +- test/tools/runner/hooks/configuration.ts | 5 ----- test/tools/runner/source_map.cjs | 4 ++++ 5 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 test/tools/runner/source_map.cjs diff --git a/.mocharc.js b/.mocharc.js index aa6841b1128..6ff6b3c09e3 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -5,8 +5,8 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ - 'source-map-support/register', 'ts-node/register', + 'test/tools/runner/source_map.cjs', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts', 'test/tools/runner/ee_checker.ts' diff --git a/test/manual/mocharc.js b/test/manual/mocharc.js index 24e435b353b..79ebc4da639 100644 --- a/test/manual/mocharc.js +++ b/test/manual/mocharc.js @@ -6,8 +6,8 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ - 'source-map-support/register', 'ts-node/register', + 'test/tools/runner/source_map.cjs', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts' ], diff --git a/test/mocha_mongodb.js b/test/mocha_mongodb.js index 26bbca90479..c86bf54f9a5 100644 --- a/test/mocha_mongodb.js +++ b/test/mocha_mongodb.js @@ -6,8 +6,8 @@ const [major] = process.versions.node.split('.'); /** @type {import("mocha").MochaOptions} */ module.exports = { require: [ - 'source-map-support/register', 'ts-node/register', + 'test/tools/runner/source_map.cjs', 'test/tools/runner/throw_rejections.cjs', 'test/tools/runner/chai_addons.ts', 'test/tools/runner/ee_checker.ts', diff --git a/test/tools/runner/hooks/configuration.ts b/test/tools/runner/hooks/configuration.ts index 0220d81fb9b..db6a50344b2 100644 --- a/test/tools/runner/hooks/configuration.ts +++ b/test/tools/runner/hooks/configuration.ts @@ -1,10 +1,5 @@ /* eslint-disable simple-import-sort/imports */ -// eslint-disable-next-line @typescript-eslint/no-require-imports -require('source-map-support').install({ - hookRequire: true -}); - import * as process from 'process'; import * as os from 'os'; diff --git a/test/tools/runner/source_map.cjs b/test/tools/runner/source_map.cjs new file mode 100644 index 00000000000..2b8bab0621e --- /dev/null +++ b/test/tools/runner/source_map.cjs @@ -0,0 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-require-imports +require('source-map-support').install({ + hookRequire: true +});