From 2651541ccf8c419e38f8ba410b485811a41dda95 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Wed, 17 Jun 2020 15:25:01 +0100 Subject: [PATCH] Fix #2496: make e2e tests exit if any single test fails --- e2e_tests/failfast.js | 7 +++++++ jest.config.js | 3 +++ package.json | 3 ++- yarn.lock | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 e2e_tests/failfast.js diff --git a/e2e_tests/failfast.js b/e2e_tests/failfast.js new file mode 100644 index 00000000..0465166a --- /dev/null +++ b/e2e_tests/failfast.js @@ -0,0 +1,7 @@ +// Borrowed from https://github.com/facebook/jest/issues/2867#issuecomment-546592968-permalink +const failFast = require("jasmine-fail-fast"); + +if (process.argv.includes("--bail")) { + const jasmineEnv = jasmine.getEnv(); + jasmineEnv.addReporter(failFast.init()); +} diff --git a/jest.config.js b/jest.config.js index e300da2c..34ac7c67 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,6 +5,9 @@ module.exports = { setupFiles: [ "jest-webextension-mock" ], + setupFilesAfterEnv: [ + "e2e_tests/failfast.js" + ], testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", globals: { "ts-jest": { diff --git a/package.json b/package.json index 7b277ad9..dfc52b7f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "flyd": "^0.2.8", "fuse.js": "^6.0.4", "immer": "^6.0.9", + "jasmine-fail-fast": "^2.0.1", "mark.js": "^8.11.1", "mithril": "^2.0.4", "ramda": "^0.27.0", @@ -54,7 +55,7 @@ "build": "sh scripts/build.sh", "clean": "rm -rf build generated", "forrest-run": "yarn run run", - "jest": "jest", + "jest": "jest --bail --runInBand", "lint": "bash hooks/pre-commit", "make-zip": "web-ext build --source-dir build --overwrite-dest", "pretty": "bash scripts/pretty.sh", diff --git a/yarn.lock b/yarn.lock index 0f04f4d0..662558bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4707,6 +4707,13 @@ istanbul-reports@^3.0.2: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" +jasmine-fail-fast@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/jasmine-fail-fast/-/jasmine-fail-fast-2.0.1.tgz#222daa16c89b675aba4ed9552d62cf0d1e759d71" + integrity sha512-En8ONwvDQOV+jyiZEZvbvUSLWSdJFj9HiWjhLdGq/V/gxs4XyST730ooe928BbRxv4bfy05OpykKuoOU4aLC5w== + dependencies: + lodash "^4.17.15" + jed@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/jed/-/jed-1.1.1.tgz#7a549bbd9ffe1585b0cd0a191e203055bee574b4"