-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjest.setup.afterEnv.mjs
More file actions
36 lines (32 loc) · 898 Bytes
/
jest.setup.afterEnv.mjs
File metadata and controls
36 lines (32 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This file runs after Jest has been initialized in the test environment
import { jest } from '@jest/globals';
// Global test timeout (30 seconds)
jest.setTimeout(30000);
// Global before/after hooks
beforeAll(async () => {
// Set up any test fixtures or mocks here
console.log('Global test setup');
});
afterAll(async () => {
// Clean up any test fixtures or mocks here
console.log('Global test teardown');
});
// Custom matchers
expect.extend({
toBeWithinRange(received, floor, ceiling) {
const pass = received >= floor && received <= ceiling;
if (pass) {
return {
message: () =>
`expected ${received} not to be within range ${floor} - ${ceiling}`,
pass: true,
};
} else {
return {
message: () =>
`expected ${received} to be within range ${floor} - ${ceiling}`,
pass: false,
};
}
},
});