@samitouri / QOS-React / commits / e240470cf1

fix failed tests on Windows #8737 (#8747)

* fix failed tests on Windows #8737 * Use regexp literal instead of `RegExp` constructor so that we don't need to bother with escaping special character like `\` and `.`. Note that by removing the path separator in regexp, I've relaxed the matching condition a little.Since there's little chance we have files like `XXXReact.d.ts`,it should not matter.

俞火江 committed Jan 12, 2017 at 22:46 UTC e240470cf11d2fa1791b73cb96e9f29e193b816c
2 files changed +6 -10
scripts/jest/ts-preprocessor.js
+3 -7
@@ -23,16 +23,12 @@ function compile(content, contentFilename) {
23 var compilerHost = {
24 getSourceFile(filename, languageVersion) {
25 var source;
26 + var jestRegex = /jest\.d\.ts/;
27 + var reactRegex = /(?:React|ReactDOM)(?:\.d)?\.ts$/;
28
27 - // `path.normalize` and `path.join` are used to turn forward slashes in
29 + // `path.normalize` is used to turn forward slashes in
30 // the file path into backslashes on Windows.
31 filename = path.normalize(filename);
30 - var reactRegex = new RegExp(
31 - path.join('/', '(?:React|ReactDOM)(?:\.d)?\.ts$')
32 - );
33 -
34 - var jestRegex = /jest\.d\.ts/;
35 -
32 if (filename === 'lib.d.ts') {
33 source = fs.readFileSync(
34 require.resolve('typescript/lib/lib.d.ts')
src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
+3 -3
@@ -31,14 +31,14 @@ describe('ReactClassEquivalence', () => {
31
32 function runJest(testFile) {
33 var cwd = process.cwd();
34 - var jestBin = path.resolve('node_modules', '.bin', 'jest');
34 + var extension = process.platform === 'win32' ? '.cmd' : '';
35 + var jestBin = path.resolve('node_modules', '.bin', 'jest' + extension);
36 var setupFile = path.resolve(
37 'scripts',
38 'jest',
39 'setupSpecEquivalenceReporter.js'
40 );
40 - var result = spawnSync('node', [
41 - jestBin,
41 + var result = spawnSync(jestBin, [
42 testFile,
43 '--setupTestFrameworkScriptFile',
44 setupFile,