node/test/sequential/test-inspector-stop-profile-after-done.js
Anna Henningsen e2ea73af04
test: make sure that inspector tests finish
PR-URL: https://github.com/nodejs/node/pull/32673
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-08 16:43:13 +02:00

31 lines
1.2 KiB
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');
async function runTests() {
const child = new NodeInstance(['--inspect-brk=0'],
`let c = 0;
const interval = setInterval(() => {
console.log(new Object());
if (c++ === 10)
clearInterval(interval);
}, ${common.platformTimeout(30)});`);
const session = await child.connectInspectorSession();
session.send([
{ method: 'Profiler.setSamplingInterval',
params: { interval: common.platformTimeout(300) } },
{ method: 'Profiler.enable' },
{ method: 'Runtime.runIfWaitingForDebugger' },
{ method: 'Profiler.start' }]);
while (await child.nextStderrString() !==
'Waiting for the debugger to disconnect...');
await session.send({ method: 'Profiler.stop' });
session.disconnect();
assert.strictEqual((await child.expectShutdown()).exitCode, 0);
}
runTests().then(common.mustCall());