Skip to content

Commit 76c2f4f

Browse files
Trottrvagg
authored andcommitted
test: simplify test-worker-syntax-error
Remove extraneous code from test-worker-syntax-error. Because the worker is called with `eval: true`, there is no need to set an environment variable indicating whether the worker has started and so on. The test file is only ever executed by the main thread. PR-URL: #26144 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent dab3d71 commit 76c2f4f

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

test/parallel/test-worker-syntax-error.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@ const common = require('../common');
33
const assert = require('assert');
44
const { Worker } = require('worker_threads');
55

6-
// Do not use isMainThread so that this test itself can be run inside a Worker.
7-
if (!process.env.HAS_STARTED_WORKER) {
8-
process.env.HAS_STARTED_WORKER = 1;
9-
const w = new Worker('abc)', { eval: true });
10-
w.on('message', common.mustNotCall());
11-
w.on('error', common.mustCall((err) => {
12-
assert.strictEqual(err.constructor, SyntaxError);
13-
assert(/SyntaxError/.test(err));
14-
}));
15-
} else {
16-
throw new Error('foo');
17-
}
6+
const w = new Worker('abc)', { eval: true });
7+
w.on('message', common.mustNotCall());
8+
w.on('error', common.mustCall((err) => {
9+
assert.strictEqual(err.constructor, SyntaxError);
10+
assert(/SyntaxError/.test(err));
11+
}));

0 commit comments

Comments
 (0)