Skip to content

Commit 00e171d

Browse files
chore: update jest
1 parent 7b34621 commit 00e171d

6 files changed

+1624
-3296
lines changed

jest-environment-fail-fast.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Circus } from '@jest/types';
2+
import { TestEnvironment } from 'jest-environment-node';
3+
4+
class FailFastEnvironment extends TestEnvironment {
5+
failedTest = false;
6+
7+
async handleTestEvent(event: Circus.Event, state: Circus.State) {
8+
if (event.name === 'hook_failure' || event.name === 'test_fn_failure') {
9+
this.failedTest = true;
10+
} else if (this.failedTest && event.name === 'test_start') {
11+
event.test.mode = 'skip';
12+
}
13+
14+
// @ts-ignore
15+
if (super.handleTestEvent) await super.handleTestEvent(event, state);
16+
}
17+
}
18+
19+
export default FailFastEnvironment;

jest.config.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
module.exports = {
22
preset: "ts-jest",
3-
testEnvironment: "node",
3+
testEnvironment: './jest-environment-fail-fast.ts',
4+
testRunner: 'jest-circus/runner',
45
testMatch: ["<rootDir>/test/**/*.spec.ts"],
56
testTimeout: 900000, // 15 minutes. Must match UPSTREAM_POLLING_CONFIGURATION in test/helpers/kubernetes-upstream.ts
67
bail: true,
78
clearMocks: true,
89
errorOnDeprecated: true,
910

10-
/** https://github.com/facebook/jest/issues/2867#issuecomment-546592968 */
11-
setupFilesAfterEnv: ["./jest.setup-after-env.js"],
12-
13-
// TODO: This is here until a bug in Jest (which in turn affects ts-jest) is resolved.
11+
// This is here until a bug in Jest (which in turn affects ts-jest) is resolved.
1412
// It affects our CI/CD runs and makes the machine run out of memory.
1513
// https://github.com/facebook/jest/issues/10550
16-
// https://snyk.slack.com/archives/CLW30N31V/p1602232569018000?thread_ts=1602230753.017500&cid=CLW30N31V
1714
globals: {
1815
"ts-jest": {
1916
isolatedModules: true,

jest.setup-after-env.js

-4
This file was deleted.

0 commit comments

Comments
 (0)