• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const fixtures = require('../common/fixtures');
5
6common.skipIfInspectorDisabled();
7common.skipIfWorker(); // This test requires both main and worker threads.
8
9const assert = require('assert');
10const { Worker, isMainThread } = require('worker_threads');
11
12if (isMainThread) {
13  const name = 'Hello Thread';
14  const expectedTitle = `[worker 1] ${name}`;
15  const worker = new Worker(fixtures.path('worker-name.js'), {
16    name,
17  });
18  worker.once('message', common.mustCall((message) => {
19    assert.strictEqual(message, expectedTitle);
20    worker.postMessage('done');
21  }));
22}
23