diff --git a/integration_tests/__tests__/regex-(char-in-path-test.js b/integration_tests/__tests__/regex-(char-in-path-test.js new file mode 100644 index 000000000000..873d4505597f --- /dev/null +++ b/integration_tests/__tests__/regex-(char-in-path-test.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails oncall+jsinfra + */ +'use strict'; + +const runJest = require('../runJest'); + +describe('Regex Char In Path', () => { + it('parses paths containing regex chars correctly', () => { + const {json} = runJest.json('regex-(char-in-path', []); + + expect(json.numTotalTests).toBe(1); + expect(json.numPassedTests).toBe(1); + }); +}); diff --git a/integration_tests/regex-(char-in-path/__tests__/regex-(char-in-path.test.js b/integration_tests/regex-(char-in-path/__tests__/regex-(char-in-path.test.js new file mode 100644 index 000000000000..8358b68f531a --- /dev/null +++ b/integration_tests/regex-(char-in-path/__tests__/regex-(char-in-path.test.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +it('runs this', () => { + expect(true).toBe(true); +}); diff --git a/integration_tests/regex-(char-in-path/package.json b/integration_tests/regex-(char-in-path/package.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/integration_tests/regex-(char-in-path/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/jest-cli/src/SearchSource.js b/packages/jest-cli/src/SearchSource.js index 8cab58178349..32fda17790ef 100644 --- a/packages/jest-cli/src/SearchSource.js +++ b/packages/jest-cli/src/SearchSource.js @@ -81,7 +81,9 @@ class SearchSource { this._options = options || {}; this._testPathDirPattern = - new RegExp(config.testPathDirs.map(dir => pathToRegex(dir)).join('|')); + new RegExp(config.testPathDirs.map(dir => { + return pathToRegex(utils.escapeStrForRegex(dir)); + }).join('|')); this._testRegex = new RegExp(pathToRegex(config.testRegex)); const ignorePattern = config.testPathIgnorePatterns; this._testIgnorePattern =