Skip to content

Commit 1cce5b4

Browse files
committedMar 29, 2023
fix: test files are not escaped.
1 parent 213c387 commit 1cce5b4

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed
 

‎examples/basic/src/test/sum.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
import { sum } from './sum';
3+
4+
it('sum 2 test case', async () => {
5+
expect(sum(1, 1)).toEqual(3);
6+
});

‎examples/basic/src/test/sum.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22

3-
export function sum(a: number, b: string) {
3+
export function sum(a: number, b: number) {
44
return a + b + (a);
55
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { sum } from './sum';
2+
3+
it('sum 2 test case', async () => {
4+
expect(sum(1, 1)).toEqual(2);
5+
});

‎packages/core/src/watcher/copyFiles.ts

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export const watcherCopyFiles = (entry: string[] = [], options: CopyFilesOptions
1717
persistent: true,
1818
});
1919
watcher.on('all', async (eventName, filepath, stats) => {
20+
if (/\.(test|spec)\.(js|jsx|ts|tsx)$/i.test(filepath)) {
21+
return;
22+
}
2023
if (
2124
!/\.(m?js|jsx?|m?ts|tsx?|c?js)$/i.test(filepath) &&
2225
rootDirsRelative &&

‎packages/typescript/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export default async function compile(options: TsCompileOptions = {}) {
8383
if (parseResult.errors.length) {
8484
return parseResult.errors.forEach(reportDiagnostic);
8585
}
86-
86+
// Test files are not escaped.
87+
parseResult.fileNames = parseResult.fileNames.filter((item) => !/\.(test|spec)\.(js|jsx|ts|tsx)$/i.test(item));
8788
const currentDir = ts.sys.getCurrentDirectory();
8889
const rootDirsRelative = [...new Set(getRootsFolderName(parseResult.fileNames))];
8990
const outputDir = path.resolve(currentDir, compilerOptions.outDir || 'lib');

0 commit comments

Comments
 (0)
Please sign in to comment.