Skip to content

Commit f024a95

Browse files
authored
Merge pull request #1183 from snyk/test/jest
test: jest fail-fast when any test fails
2 parents 6da1561 + 9b94259 commit f024a95

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module.exports = {
77
clearMocks: true,
88
errorOnDeprecated: true,
99

10+
/** https://github.com/facebook/jest/issues/2867#issuecomment-546592968 */
11+
setupFilesAfterEnv: ["./jest.setup-after-env.js"],
12+
1013
// TODO: This is here until a bug in Jest (which in turn affects ts-jest) is resolved.
1114
// It affects our CI/CD runs and makes the machine run out of memory.
1215
// https://github.com/facebook/jest/issues/10550

jest.setup-after-env.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const failFast = require("jasmine-fail-fast");
2+
3+
const jasmineEnv = jasmine.getEnv();
4+
jasmineEnv.addReporter(failFast.init());

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"eslint-config-prettier": "^8.3.0",
7070
"eslint-plugin-prettier": "^3.4.1",
7171
"fadge": "^0.0.1",
72+
"jasmine-fail-fast": "^2.0.1",
7273
"jest": "^26.6.3",
7374
"nock": "^13.0.11",
7475
"prettier": "^2.4.1",

test/integration/kubernetes.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ async function teardown(): Promise<void> {
2929
console.log('Removed "kind" network');
3030
}
3131

32-
beforeAll(teardown);
3332
afterAll(teardown);
3433

34+
test('clean up environment on start', teardown);
35+
3536
// Make sure this runs first -- deploying the monitor for the next tests
3637
test('deploy snyk-monitor', async () => {
3738
namespace = setup.snykMonitorNamespace();

0 commit comments

Comments
 (0)