diff --git a/test/parallel/test-worker-type-check.js b/test/parallel/test-worker-type-check.js new file mode 100644 index 00000000000000..43013bc538712a --- /dev/null +++ b/test/parallel/test-worker-type-check.js @@ -0,0 +1,28 @@ +// Flags: --experimental-worker +'use strict'; + +const common = require('../common'); +const { Worker } = require('worker_threads'); + +{ + [ + undefined, + null, + false, + 0, + Symbol('test'), + {}, + [], + () => {} + ].forEach((val) => { + common.expectsError( + () => new Worker(val), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "filename" argument must be of type string. ' + + `Received type ${typeof val}` + } + ); + }); +}