node/test/sequential/test-debugger-profile.js
surbhirjain 2baa3c3ce5 test: use async/await in test-debugger-profile
PR-URL: https://github.com/nodejs/node/pull/44684
Reviewed-By: Rich Trott <rtrott@gmail.com>
2022-10-11 14:45:29 -05:00

41 lines
948 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');
const assert = require('assert');
function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
// Profiles.
{
const cli = startCLI([fixtures.path('debugger/empty.js')]);
function onFatal(error) {
cli.quit();
throw error;
}
try {
(async () => {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
await cli.command('exec console.profile()');
assert.match(cli.output, /undefined/);
await cli.command('exec console.profileEnd()');
await delay(250);
assert.match(cli.output, /undefined/);
assert.match(cli.output, /Captured new CPU profile\./);
await cli.quit();
})()
.then(common.mustCall());
} catch (error) {
return onFatal(error);
}
}