From 200357596aed51d5a71cac0996e3a0510e507156 Mon Sep 17 00:00:00 2001 From: Sophie Alpert Date: Tue, 1 May 2018 12:46:17 -0700 Subject: [PATCH] Add error when running jest directly (#12726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` $ jest FAIL scripts/jest/dont-run-jest-directly.js ● Test suite failed to run Don't run `jest` directly. Run `yarn test` instead. > 1 | throw new Error("Don't run `jest` directly. Run `yarn test` instead."); 2 | at Object. (scripts/jest/dont-run-jest-directly.js:1:96) Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 0.866s Ran all test suites. ``` --- package.json | 3 +++ scripts/jest/dont-run-jest-directly.js | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 scripts/jest/dont-run-jest-directly.js diff --git a/package.json b/package.json index 01f0a2781f..9b625ea397 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,9 @@ "devEngines": { "node": "8.x || 9.x" }, + "jest": { + "testRegex": "/scripts/jest/dont-run-jest-directly\\.js$" + }, "scripts": { "build": "npm run version-check && node ./scripts/rollup/build.js", "flow-coverage": "flow-coverage-report --config ./.flowcoverage", diff --git a/scripts/jest/dont-run-jest-directly.js b/scripts/jest/dont-run-jest-directly.js new file mode 100644 index 0000000000..672d07caec --- /dev/null +++ b/scripts/jest/dont-run-jest-directly.js @@ -0,0 +1,3 @@ +'use strict'; + +throw new Error("Don't run `jest` directly. Run `yarn test` instead.");