Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Jest on Windows #1463

Merged
merged 1 commit into from
Aug 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "2.0.0-beta.24",
"lerna": "2.0.0-beta.26",
"version": "14.1.3",
"linkedFiles": {
"prefix": "/**\n * @flow\n */\n"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"graceful-fs": "^4.1.5",
"istanbul-api": "^1.0.0-aplha.10",
"istanbul-lib-coverage": "^1.0.0",
"lerna": "2.0.0-beta.24",
"lerna": "2.0.0-beta.26",
"minimatch": "^3.0.3",
"mkdirp": "^0.5.1",
"progress": "^1.1.8",
Expand All @@ -28,7 +28,7 @@
"build-clean": "rm -rf ./packages/*/build",
"build": "node ./scripts/build.js",
"clean-all": "rm -rf ./packages/*/node_modules; rm -rf ./integration_tests/*/*/node_modules; npm run build-clean",
"jest": "./packages/jest-cli/bin/jest.js",
"jest": "node ./packages/jest-cli/bin/jest.js",
"jest-coverage": "npm run jest -- --coverage",
"lint": "eslint .",
"postinstall": "node ./scripts/postinstall.js && node ./scripts/build.js",
Expand Down Expand Up @@ -65,6 +65,6 @@
"\\.snap$",
"packages/.*/build"
],
"testRegex": ".*-test.\\js"
"testRegex": ".*-test\\.js"
}
}
7 changes: 4 additions & 3 deletions packages/jest-cli/src/SearchSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class SearchSource {
this._options = options || {};

this._testPathDirPattern =
new RegExp(config.testPathDirs.map(dir => {
return pathToRegex(utils.escapeStrForRegex(dir));
}).join('|'));
new RegExp(config.testPathDirs.map(
dir => utils.escapePathForRegex(dir),
).join('|'));

this._testRegex = new RegExp(pathToRegex(config.testRegex));
const ignorePattern = config.testPathIgnorePatterns;
this._testIgnorePattern =
Expand Down
10 changes: 10 additions & 0 deletions packages/jest-util/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');

const escapePathForRegex = (dir: string) => {
if (path.sep === '\\') {
// Replace "\" with "/" so it's not escaped by escapeStrForRegex.
// replacePathSepForRegex will convert it back.
dir = dir.replace(/\\/g, '/');
}
return replacePathSepForRegex(escapeStrForRegex(dir));
};

const escapeStrForRegex =
(string: string) => string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');

Expand Down Expand Up @@ -57,6 +66,7 @@ exports.NullConsole = require('./NullConsole');

exports.clearLine = require('./clearLine');
exports.createDirectory = createDirectory;
exports.escapePathForRegex = escapePathForRegex;
exports.escapeStrForRegex = escapeStrForRegex;
exports.formatResultsErrors =
require('./formatFailureMessage').formatResultsErrors;
Expand Down