MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-inspector-has-idle.js:12–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10const sleep = promisify(setTimeout);
11
12async function test() {
13 const inspector = new Session();
14 inspector.connect();
15
16 inspector.post('Profiler.enable');
17 inspector.post('Profiler.start');
18
19 await sleep(1000);
20
21 const { profile } = await new Promise((resolve, reject) => {
22 inspector.post('Profiler.stop', (err, params) => {
23 if (err) return reject(err);
24 resolve(params);
25 });
26 });
27
28 let hasIdle = false;
29 for (const node of profile.nodes) {
30 if (node.callFrame.functionName === '(idle)') {
31 hasIdle = true;
32 break;
33 }
34 }
35 assert(hasIdle);
36
37 inspector.post('Profiler.disable');
38 inspector.disconnect();
39}
40
41test().then(common.mustCall(() => {
42 console.log('Done!');

Callers 1

Calls 7

connectMethod · 0.95
postMethod · 0.95
disconnectMethod · 0.95
sleepFunction · 0.50
rejectFunction · 0.50
resolveFunction · 0.50
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…