Spaces:
Sleeping
Sleeping
File size: 835 Bytes
6491ad4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 'use strict'
/**
* This file is packaged using pkg in order to test if worker.js works in that context
*/
const { test } = require('tap')
const { join } = require('path')
const { file } = require('../helper')
const ThreadStream = require('../..')
test('bundlers support with .js file', function (t) {
t.plan(1)
globalThis.__bundlerPathsOverrides = {
'thread-stream-worker': join(__dirname, '..', 'custom-worker.js')
}
const dest = file()
process.on('uncaughtException', (error) => {
console.log(error)
})
const stream = new ThreadStream({
filename: join(__dirname, '..', 'to-file.js'),
workerData: { dest },
sync: true
})
stream.worker.removeAllListeners('message')
stream.worker.once('message', (message) => {
t.equal(message.code, 'CUSTOM-WORKER-CALLED')
})
stream.end()
})
|