Skip to content

Commit

Permalink
fix: do not show warnings in workers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kabir-Ivan committed Aug 9, 2024
1 parent 4c32f01 commit 9a43381
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/base-testplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export abstract class BaseTestplane extends AsyncEmitter {

this._interceptors = [];

tryToRegisterTsNode();
tryToRegisterTsNode(this.isWorker());

this._config = Config.create(config);
this._setLogLevel();
Expand Down
28 changes: 16 additions & 12 deletions src/utils/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from "lodash";
import logger from "./logger";

export const tryToRegisterTsNode = (): void => {
export const tryToRegisterTsNode = (isWorker: boolean = false): void => {
if (process.env.TS_ENABLE === "false") {
return;
}
Expand Down Expand Up @@ -31,12 +31,14 @@ export const tryToRegisterTsNode = (): void => {
return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
if (err.code === "MODULE_NOT_FOUND") {
logger.warn(
`testplane: you may install @swc/core for significantly faster reading of typescript tests.`,
);
} else {
logger.warn(`testplane: could not load @swc/core:`, err);
if (!isWorker) {
if (err.code === "MODULE_NOT_FOUND") {
logger.warn(
`testplane: you may install @swc/core for significantly faster reading of typescript tests.`,
);
} else {
logger.warn(`testplane: could not load @swc/core:`, err);
}
}
}
}
Expand Down Expand Up @@ -64,11 +66,13 @@ export const tryToRegisterTsNode = (): void => {
return;
// eslint-disable-next-line no-empty
} catch (err) {
const params = `swc: "false", transpileOnly: "${transpileOnlyRaw}", skipProject: "${skipProjectRaw}"`;
logger.warn(
`testplane: an error occured while trying to register ts-node (${params}). TypeScript tests won't be read:`,
err,
);
if (!isWorker) {
const params = `swc: "false", transpileOnly: "${transpileOnlyRaw}", skipProject: "${skipProjectRaw}"`;
logger.warn(
`testplane: an error occured while trying to register ts-node (${params}). TypeScript tests won't be read:`,
err,
);
}
}
} catch {} // eslint-disable-line no-empty
};

0 comments on commit 9a43381

Please sign in to comment.