* 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.
This commit is contained in:
parent
cb82bc37b6
commit
e240470cf1
|
@ -23,16 +23,12 @@ function compile(content, contentFilename) {
|
|||
var compilerHost = {
|
||||
getSourceFile(filename, languageVersion) {
|
||||
var source;
|
||||
var jestRegex = /jest\.d\.ts/;
|
||||
var reactRegex = /(?:React|ReactDOM)(?:\.d)?\.ts$/;
|
||||
|
||||
// `path.normalize` and `path.join` are used to turn forward slashes in
|
||||
// `path.normalize` is used to turn forward slashes in
|
||||
// the file path into backslashes on Windows.
|
||||
filename = path.normalize(filename);
|
||||
var reactRegex = new RegExp(
|
||||
path.join('/', '(?:React|ReactDOM)(?:\.d)?\.ts$')
|
||||
);
|
||||
|
||||
var jestRegex = /jest\.d\.ts/;
|
||||
|
||||
if (filename === 'lib.d.ts') {
|
||||
source = fs.readFileSync(
|
||||
require.resolve('typescript/lib/lib.d.ts')
|
||||
|
|
|
@ -31,14 +31,14 @@ describe('ReactClassEquivalence', () => {
|
|||
|
||||
function runJest(testFile) {
|
||||
var cwd = process.cwd();
|
||||
var jestBin = path.resolve('node_modules', '.bin', 'jest');
|
||||
var extension = process.platform === 'win32' ? '.cmd' : '';
|
||||
var jestBin = path.resolve('node_modules', '.bin', 'jest' + extension);
|
||||
var setupFile = path.resolve(
|
||||
'scripts',
|
||||
'jest',
|
||||
'setupSpecEquivalenceReporter.js'
|
||||
);
|
||||
var result = spawnSync('node', [
|
||||
jestBin,
|
||||
var result = spawnSync(jestBin, [
|
||||
testFile,
|
||||
'--setupTestFrameworkScriptFile',
|
||||
setupFile,
|
||||
|
|
Loading…
Reference in New Issue