You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to the typescript world, i'm trying to test a node js app using node:worker_threads
It seems tsx run the code if i'm passing a .ts file to the new Worker constructor but i cannot make it work with vitest am i missing something ?
Is there a better way to test apps that leverage node:worker_threads ?
Best !
DEV v0.30.1 /Users/afa/code
stderr | src/tmp/index.test.ts > worker > worker
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/afa/code/src/tmp/worker.ts
at new NodeError (node:internal/errors:399:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
at defaultLoad (node:internal/modules/esm/load:81:20)
at nextLoad (node:internal/modules/esm/loader:163:28)
at ESMLoader.load (node:internal/modules/esm/loader:605:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
at new ModuleJob (node:internal/modules/esm/module_job:64:26)
at #createModuleJob (node:internal/modules/esm/loader:480:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
Reproduction
index.ts
import{Worker}from'node:worker_threads'exportconsttestWorker=()=>{constworker=newWorker(newURL('worker.ts',import.meta.url))worker.once('error',console.error)worker.once('online',()=>{worker.postMessage('hello from main')})worker.on('message',console.log)returnworker}
Describe the bug
Hey thanks for the awesone tool !
I'm new to the typescript world, i'm trying to test a node js app using
node:worker_threads
It seems
tsx
run the code if i'm passing a.ts
file to thenew Worker
constructor but i cannot make it work withvitest
am i missing something ?Is there a better way to test apps that leverage
node:worker_threads
?Best !
Reproduction
index.ts
worker.ts
index.test.ts
vitest.config.ts
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: