Skip to content

Commit

Permalink
feat: add ability to use import and export in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Mar 7, 2024
1 parent 03d40dd commit e70cc61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const tryToRegisterTsNode = (): void => {
skipProject: JSON.parse(skipProjectRaw),
transpileOnly: JSON.parse(transpileOnlyRaw),
swc: JSON.parse(swcRaw),
compilerOptions: {
allowJs: true,
},
});
} catch (err) {
const params = `swc: "${swcRaw}", transpileOnly: "${transpileOnlyRaw}", skipProject: "${skipProjectRaw}"`;
Expand Down
13 changes: 13 additions & 0 deletions test/src/utils/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ describe("utils/typescript", () => {
assert.notCalled(registerStub);
});

it("should pass 'allowJs' option", () => {
ts.tryToRegisterTsNode();

assert.calledOnceWith(
registerStub,
sinon.match({
compilerOptions: {
allowJs: true,
},
}),
);
});

it("should respect env vars", () => {
process.env.TS_NODE_SKIP_PROJECT = "false";
process.env.TS_NODE_TRANSPILE_ONLY = "false";
Expand Down

0 comments on commit e70cc61

Please sign in to comment.