8000 Speed up test runs (#1342) · lisongyu/immutable-js@0122fef · GitHub
[go: up one dir, main page]

Skip to content

Commit 0122fef

Browse files
authored
Speed up test runs (immutable-js#1342)
This replaces type checking of tests with a simple transpile, which makes running tests 10x faster. This is possible without reducing test coverage by the recent addition of ts-tests which performs type checking against the typescript tests.
1 parent 5d9fd21 commit 0122fef

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

resources/jestPreprocessor.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,18 @@
77

88
var typescript = require('typescript');
99

10-
module.exports = {
11-
process: function(src, filePath) {
12-
var compiled;
13-
14-
var options = {
15-
noEmitOnError: true,
16-
target: typescript.ScriptTarget.ES2015,
17-
module: typescript.ModuleKind.CommonJS,
18-
strictNullChecks: true,
19-
};
20-
21-
var host = typescript.createCompilerHost(options);
22-
var program = typescript.createProgram([filePath], options, host);
23-
24-
host.writeFile = (name, text) => compiled = text;
25-
var emitResult = program.emit();
26-
var diagnostics = typescript.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
10+
var options = {
11+
noEmitOnError: true,
12+
target: typescript.ScriptTarget.ES2015,
13+
module: typescript.ModuleKind.CommonJS,
14+
strictNullChecks: true,
15+
};
2716

28-
if (diagnostics.length === 0) {
29-
return compiled;
17+
module.exports = {
18+
process(src, path) {
19+
if (path.endsWith('.ts') || path.endsWith('.tsx')) {
20+
return typescript.transpile(src, options, path, []);
3021
}
31-
32-
var report = typescript.formatDiagnostics(diagnostics, host);
33-
throw new Error('Compiling ' + filePath + ' failed' + '\n' + report);
34-
}
22+
return src;
23+
},
3524
};

0 commit comments

Comments
 (0)
0