forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
31 lines (28 loc) · 1.27 KB
/
Copy pathjest.setup.js
File metadata and controls
31 lines (28 loc) · 1.27 KB
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
// Expose shared backend test utilities for Jest-based tests.
global.testUtils = require('./tests/utils');
// Suppress console.error during tests to reduce noise from expected validation errors
jest.spyOn(console, 'error').mockImplementation(() => {});
// ── Global test timeout ───────────────────────────────────────────────────
// Matches the value in jest.config.js; set here as well so it applies even
// when jest.config.js is not loaded (e.g. --config override in one-off runs).
jest.setTimeout(15000);
// ── Custom matchers ───────────────────────────────────────────────────────
/**
* .toBeValidJwt()
* Asserts that a value is a string with the three-part JWT structure.
*/
expect.extend({
toBeValidJwt(received) {
const pass =
typeof received === 'string' &&
received.split('.').length === 3 &&
received.length > 20;
return {
pass,
message: () =>
pass
? `expected "${received}" NOT to be a valid JWT`
: `expected a three-part JWT string, received: ${JSON.stringify(received)}`,
};
},
});