-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjest.setup.ts
More file actions
32 lines (26 loc) · 1.21 KB
/
jest.setup.ts
File metadata and controls
32 lines (26 loc) · 1.21 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
/**
* Global Jest Setup File
*
* Suppresses expected SDK validation errors to reduce console noise during tests.
* These errors are intentional - tests verify that the SDK handles invalid inputs gracefully.
*/
// Store the original console.error for genuine errors
const originalConsoleError = console.error;
// List of expected SDK validation errors to suppress
const expectedErrors = [
'Invalid key:', // From query.search() validation
'Invalid value (expected string or number):', // From query.equalTo() validation
'Argument should be a String or an Array.', // From entry/entries.includeReference() validation
'Invalid fieldUid:', // From asset query validation
];
// Override console.error globally to filter expected validation errors
console.error = (...args: any[]) => {
const message = args[0]?.toString() || '';
// Check if this is an expected SDK validation error
const isExpectedError = expectedErrors.some(pattern => message.includes(pattern));
// If not expected, show it (for genuine errors)
if (!isExpectedError) {
originalConsoleError.apply(console, args);
}
// Otherwise, silently suppress it
};