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

Function basic

test/report/test-report-worker.js:8–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const helper = require('../common/report');
7
8async function basic() {
9 // Test that the report includes basic information about Worker threads.
10
11 const w = new Worker(`
12 const { parentPort } = require('worker_threads');
13 parentPort.once('message', () => {
14 /* Wait for message to stop the Worker */
15 });
16 `, { eval: true, name: 'hello' });
17
18 await once(w, 'online');
19
20 const report = process.report.getReport();
21 helper.validateContent(report);
22 assert.strictEqual(report.workers.length, 1);
23 helper.validateContent(report.workers[0]);
24 assert.strictEqual(report.workers[0].header.threadId, w.threadId);
25 assert.strictEqual(report.workers[0].header.event,
26 'Worker thread subreport [hello]',
27 report.workers[0].header.event);
28 w.postMessage({});
29
30 await once(w, 'exit');
31}
32
33async function interruptingJS() {
34 // Test that the report also works when Worker threads are busy in JS land.

Callers 1

Calls 2

postMessageMethod · 0.95
onceFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…