diff --git a/CHANGELOG.md b/CHANGELOG.md index d9a4ea35d2b2..36682127615e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## master +### Fixes + +* `[jest-cli]` Fix `EISDIR` when a directory is passed as an argument to `jest`. + ([#5317](https://github.com/facebook/jest/pull/5317)) + ## jest 22.1.0 ### Features diff --git a/integration-tests/__tests__/__snapshots__/cli-accepts-exact-filenames.test.js.snap b/integration-tests/__tests__/__snapshots__/cli-accepts-exact-filenames.test.js.snap index 6c75b05c0a40..14f0f7d5b8bc 100644 --- a/integration-tests/__tests__/__snapshots__/cli-accepts-exact-filenames.test.js.snap +++ b/integration-tests/__tests__/__snapshots__/cli-accepts-exact-filenames.test.js.snap @@ -22,7 +22,7 @@ exports[`CLI accepts exact filenames 2`] = ` Tests: 2 passed, 2 total Snapshots: 0 total Time: <> -Ran all test suites matching /.\\\\/bar.js|.\\\\/foo\\\\/baz.js/i. +Ran all test suites matching /.\\\\/bar.js|.\\\\/foo\\\\/baz.js|.\\\\/foo/i. " `; diff --git a/integration-tests/__tests__/cli-accepts-exact-filenames.test.js b/integration-tests/__tests__/cli-accepts-exact-filenames.test.js index 9b5aee992b1a..0ef90d7da4fd 100644 --- a/integration-tests/__tests__/cli-accepts-exact-filenames.test.js +++ b/integration-tests/__tests__/cli-accepts-exact-filenames.test.js @@ -38,6 +38,7 @@ test('CLI accepts exact filenames', () => { '--forceExit', './bar.js', './foo/baz.js', + './foo', ]); const {rest, summary} = extractSummary(stderr); expect(status).toBe(0); diff --git a/packages/jest-cli/src/search_source.js b/packages/jest-cli/src/search_source.js index d27d3b83a603..b49fbae44ee1 100644 --- a/packages/jest-cli/src/search_source.js +++ b/packages/jest-cli/src/search_source.js @@ -209,7 +209,15 @@ export default class SearchSource { } else if (globalConfig.findRelatedTests && paths && paths.length) { return Promise.resolve(this.findRelatedTestsFromPattern(paths)); } else { - const validTestPaths = paths && paths.filter(fs.existsSync); + const validTestPaths = + paths && + paths.filter(name => { + try { + return fs.lstatSync(name).isFile(); + } catch (e) { + return false; + } + }); if (validTestPaths && validTestPaths.length) { return Promise.resolve({tests: toTests(this._context, validTestPaths)});