1'use strict'; 2const common = require('../common'); 3const fixtures = require('../common/fixtures'); 4const assert = require('assert'); 5const { Worker } = require('worker_threads'); 6 7// Do not use isMainThread so that this test itself can be run inside a Worker. 8if (!process.env.HAS_STARTED_WORKER) { 9 process.env.HAS_STARTED_WORKER = 1; 10 const w = new Worker(fixtures.path('syntax', 'bad_syntax.js')); 11 w.on('message', common.mustNotCall()); 12 w.on('error', common.mustCall((err) => { 13 assert.strictEqual(err.constructor, SyntaxError); 14 assert.strictEqual(err.name, 'SyntaxError'); 15 })); 16} else { 17 throw new Error('foo'); 18} 19