Skip to content

Commit dcb926a

Browse files
authored
fix: register ts-node in test environments if consumer project passes a .ts source file (#47)
1 parent 9aa6c52 commit dcb926a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/helpers/worker-thread-manager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as WorkerThreads from 'node:worker_threads';
22
import * as os from 'node:os';
3-
import * as path from 'node:path';
43
import { EventEmitter, addAbortListener } from 'node:events';
54
import { waiter, Waiter } from './time';
65
import { deserializeError, isErrorLike } from './serialize-error';
@@ -124,7 +123,9 @@ export class WorkerThreadManager<TArgs extends unknown[], TResp> {
124123
const workerOpt: WorkerThreads.WorkerOptions = {
125124
workerData,
126125
};
127-
if (path.extname(workerThreadInitFilename) === '.ts') {
126+
const hasTsSource =
127+
workerThreadInitFilename.endsWith('.ts') || this.workerFile.endsWith('.ts');
128+
if (hasTsSource) {
128129
if (process.env.NODE_ENV !== 'test') {
129130
throw new Error(
130131
'Worker threads are being created with ts-node outside of a test environment'

0 commit comments

Comments
 (0)