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

Function test

test/parallel/test-trace-events-dynamic-enable.js:41–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39}
40
41async function test() {
42 session.connect();
43
44 const events = [];
45 let tracingComplete = false;
46 session.on('NodeTracing.dataCollected', common.mustCall((n) => {
47 assert.ok(n?.params?.value);
48 events.push(...n.params.value); // append the events.
49 }, 2));
50 session.on('NodeTracing.tracingComplete', () => tracingComplete = true);
51
52 trace(kBeforeEvent, 'foo', 'test1', 0, 'test');
53
54 const traceConfig = { includedCategories: ['foo'] };
55 await post('NodeTracing.start', { traceConfig });
56
57 trace(kBeforeEvent, 'foo', 'test2', 0, 'test');
58 trace(kBeforeEvent, 'bar', 'test3', 0, 'test');
59
60 await post('NodeTracing.stop', { traceConfig });
61
62 trace(kBeforeEvent, 'foo', 'test4', 0, 'test');
63 session.disconnect();
64
65 assert.ok(tracingComplete);
66
67 const marks = events.filter((t) => null !== /foo/.exec(t.cat));
68 assert.strictEqual(marks.length, 1);
69 assert.strictEqual(marks[0].name, 'test2');
70}
71
72test();

Calls 9

traceFunction · 0.85
postFunction · 0.70
connectMethod · 0.65
disconnectMethod · 0.65
filterMethod · 0.65
onMethod · 0.45
okMethod · 0.45
pushMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…