0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/sequential/test-inspector-overwrite-config.js
Michaël Zasso df08779e0d
test: make crashOnUnhandleRejection opt-out
This commit removes `common.crashOnUnhandledRejection()` and adds
`common.disableCrashOnUnhandledRejection()`.

To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for the rare cases where it's needed.

PR-URL: https://github.com/nodejs/node/pull/21849
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-07-19 08:47:28 +02:00

45 lines
1.4 KiB
JavaScript

// Flags: --require ./test/fixtures/overwrite-config-preload-module.js
'use strict';
// This test ensures that overwriting a process configuration
// value does not affect code in lib/internal/bootstrap/node.js.
// Specifically this tests
// that the inspector console functions are bound even though
// overwrite-config-preload-module.js overwrote the process.config variable.
// We cannot do a check for the inspector because the configuration variables
// were reset/removed by overwrite-config-preload-module.js.
/* eslint-disable node-core/inspector-check */
const common = require('../common');
const assert = require('assert');
if (!common.isMainThread)
common.skip('--require does not work with Workers');
const inspector = require('inspector');
const msg = 'Test inspector logging';
let asserted = false;
async function testConsoleLog() {
const session = new inspector.Session();
session.connect();
session.on('inspectorNotification', (data) => {
if (data.method === 'Runtime.consoleAPICalled') {
assert.strictEqual(data.params.args.length, 1);
assert.strictEqual(data.params.args[0].value, msg);
asserted = true;
}
});
session.post('Runtime.enable');
console.log(msg);
session.disconnect();
}
async function runTests() {
await testConsoleLog();
assert.ok(asserted, 'log statement did not reach the inspector');
}
runTests();