summaryrefslogtreecommitdiff
path: root/test/addons/hello-world/test-worker.js
blob: 2effcb4fa4d945b1f73e9284d3caed88fc2c2e1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
'use strict';
const common = require('../../common');
const assert = require('assert');
const path = require('path');
const { Worker } = require('worker_threads');
const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`);

const w = new Worker(`
require('worker_threads').parentPort.postMessage(
  require(${JSON.stringify(binding)}).hello());`, { eval: true });
w.on('message', common.mustCall((message) => {
  assert.strictEqual(message, 'world');
}));