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

Function test

test/parallel/test-inspector-tracing-domain.js:39–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39async function test() {
40 // This interval ensures Node does not terminate till the test is finished.
41 // Inspector session does not keep the node process running (e.g. it does not
42 // have async handles on the main event loop). It is debatable whether this
43 // should be considered a bug, and there are no plans to fix it atm.
44 const interval = setInterval(() => {}, 5000);
45 session.connect();
46 let traceNotification = null;
47 let tracingComplete = false;
48 session.on('NodeTracing.dataCollected', (n) => traceNotification = n);
49 session.on('NodeTracing.tracingComplete', () => tracingComplete = true);
50 const { categories } = await post('NodeTracing.getCategories');
51 const expectedCategories = [
52 'node',
53 'node.async_hooks',
54 'node.bootstrap',
55 'node.console',
56 'node.dns.native',
57 'node.environment',
58 'node.fs.async',
59 'node.fs.sync',
60 'node.fs_dir.async',
61 'node.fs_dir.sync',
62 'node.http',
63 'node.net.native',
64 'node.perf',
65 'node.perf.timerify',
66 'node.perf.usertiming',
67 'node.promises.rejections',
68 'node.threadpoolwork.async',
69 'node.threadpoolwork.sync',
70 'node.vm.script',
71 'v8',
72 ].sort();
73 assert.ok(categories.length === expectedCategories.length);
74 categories.forEach((category, index) => {
75 const value = expectedCategories[index];
76 assert.ok(category === value, `${category} is out of order, expect ${value}`);
77 });
78
79 const traceConfig = { includedCategories: ['v8'] };
80 await post('NodeTracing.start', { traceConfig });
81
82 for (let i = 0; i < 5; i++)
83 await generateTrace();
84 JSON.stringify(await post('NodeTracing.stop', { traceConfig }));
85 session.disconnect();
86 assert(traceNotification.params.value.length > 0);
87 assert(tracingComplete);
88 clearInterval(interval);
89 console.log('Success');
90}
91
92test().then(common.mustCall());

Calls 12

generateTraceFunction · 0.85
clearIntervalFunction · 0.85
sortMethod · 0.80
postFunction · 0.70
connectMethod · 0.65
forEachMethod · 0.65
disconnectMethod · 0.65
setIntervalFunction · 0.50
assertFunction · 0.50
onMethod · 0.45
okMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…