-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbefore-tests.js
More file actions
34 lines (30 loc) · 865 Bytes
/
before-tests.js
File metadata and controls
34 lines (30 loc) · 865 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
/* eslint-env node */
import 'url-search-params-polyfill';
// Suppress act() warnings only for async markdown rendering (SyncMarkdownView /
// QuickStartMarkdownView). Other act warnings still surface so new tests stay honest.
const originalError = console.error;
const isMarkdownActWarning = (...args) => {
const message = args
.map((a) => {
if (typeof a === 'string') {
return a;
}
if (a instanceof Error && typeof a.message === 'string') {
return a.message;
}
return '';
})
.join('\n');
if (!message.includes('was not wrapped in act(')) {
return false;
}
return (
message.includes('SyncMarkdownView') || message.includes('QuickStartMarkdownView')
);
};
console.error = (...args) => {
if (isMarkdownActWarning(...args)) {
return;
}
originalError.call(console, ...args);
};