node/test/sequential/test-inspector-console.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

39 lines
937 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
async function runTest() {
const script = 'require(\'inspector\').console.log(\'hello world\');';
const child = new NodeInstance('--inspect-brk=0', script, '');
let out = '';
child.on('stdout', (line) => out += line);
const session = await child.connectInspectorSession();
const commands = [
{ 'method': 'Runtime.enable' },
{ 'method': 'Runtime.runIfWaitingForDebugger' }
];
session.send(commands);
const msg = await session.waitForNotification('Runtime.consoleAPICalled');
assert.strictEqual(msg.params.type, 'log');
assert.deepStrictEqual(msg.params.args, [{
type: 'string',
value: 'hello world'
}]);
assert.strictEqual(out, '');
session.disconnect();
}
runTest();