Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const [major] = process.versions.node.split('.');
module.exports = {
require: [
'test/mocha_root_hooks.ts',
'source-map-support/register',
'ts-node/register',
'test/tools/runner/throw_rejections.cjs',
'test/tools/runner/chai_addons.ts',
Expand All @@ -19,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']
};
3 changes: 3 additions & 0 deletions package.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: source-map-support is no longer used, remove?

Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@
"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:debug": "npm run mocha:debug -- --config test/mocha_mongodb.js test/integration",
"check:test-bundled": "MONGODB_BUNDLED=true npm run check:test",
"check:unit": "npm run build:bundle && nyc mocha test/unit",
"check:unit:debug": "npm run mocha:debug -- test/unit",
Comment thread
PavelSafronov marked this conversation as resolved.
"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",
Expand All @@ -157,6 +159,7 @@
"check:csfle": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration/client-side-encryption",
"check:snappy": "npm run build:bundle && nyc mocha test/unit/assorted/snappy.test.js",
"check:x509": "npm run build:bundle && nyc mocha test/manual/x509_auth.test.ts",
"mocha:debug": "npm run build:bundle && node --inspect --enable-source-maps --no-experimental-strip-types ./node_modules/mocha/bin/mocha.js",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The flag --no-experimental-strip-types doesn't exist in Node.js v20, so this fails in that environment:

15:11:52 ~/code/node-mongodb-native 
$ node --version
v20.20.2
15:11:57 ~/code/node-mongodb-native 
$ npm run check:unit:debug

> mongodb@7.2.0 check:unit:debug
> npm run mocha:debug -- test/unit


> mongodb@7.2.0 mocha:debug
> npm run build:bundle && node --inspect --enable-source-maps --no-experimental-strip-types ./node_modules/mocha/bin/mocha.js test/unit


> mongodb@7.2.0 build:bundle
> npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel


> mongodb@7.2.0 bundle:driver
> node etc/bundle-driver.mjs


  test/tools/runner/bundle/driver-bundle.js  3.7mb ⚠️

⚡ Done in 38ms
✓ Driver bundle created at /Users/pavel.safronov/code/node-mongodb-native/test/tools/runner/bundle/driver-bundle.js

> mongodb@7.2.0 bundle:types
> npx tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --declarationDir test/tools/runner/bundle/types


> mongodb@7.2.0 build:runtime-barrel
> node etc/build-runtime-barrel.mjs

✓ /Users/pavel.safronov/code/node-mongodb-native/test/mongodb.ts now re-exports from ./mongodb_all
node: bad option: --no-experimental-strip-types
Result=9

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

check:unit:debug doesn't have a config specified, unlike check:test:debug

check:test:debug uses test/mocha_mongodb.js which has the following:

  'node-option':
    Number(major) >= 23
      ? ['enable-source-maps', 'no-experimental-strip-types']
      : ['enable-source-maps']

This guards against using --no-experimental-strip-types if it's unsupported.

I suspect this worked for me because the same line got slipped into .vscode/.mocharc.js file in the .vscode folder, which was not committed.

Similarly, is there a .mocharc.js that we can specify to pass in check:unit:debug? Because then the same protections will come free. The most viable candidate is the one I see in the root directory.

"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",
Expand Down
5 changes: 4 additions & 1 deletion test/manual/mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,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']
Comment thread
tadjik1 marked this conversation as resolved.
};
5 changes: 4 additions & 1 deletion test/mocha_lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
};
6 changes: 4 additions & 2 deletions test/mocha_mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const [major] = process.versions.node.split('.');
module.exports = {
require: [
'test/mocha_root_hooks.ts',
'source-map-support/register',
'ts-node/register',
'test/tools/runner/throw_rejections.cjs',
'test/tools/runner/chai_addons.ts',
Expand All @@ -32,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']
};
5 changes: 0 additions & 5 deletions test/tools/runner/hooks/configuration.ts
Original file line number Diff line number Diff line change
@@ -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
});
Comment on lines -3 to -6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't this make integration tests not debug with the correct lines? I know we didn't discover how to replicate this for unit tests but does it make sense to remove for int?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FFTR, we know the real fix is c8 and it's on the horizon


import * as process from 'process';
import * as os from 'os';

Expand Down
Loading