Skip to content

Commit 93f47e5

Browse files
authored
Merge 0f0b5bd into 023451a
2 parents 023451a + 0f0b5bd commit 93f47e5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

jest.setup.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ if (!global.TextDecoder) {
1010
global.TextDecoder = TextDecoder;
1111
}
1212

13+
// window.matchMedia doesn't exist in test environment
14+
Object.defineProperty(window, 'matchMedia', {
15+
writable: true,
16+
value: jest.fn().mockImplementation(query => ({
17+
matches: false,
18+
media: query,
19+
onchange: null,
20+
addListener: jest.fn(), // deprecated
21+
removeListener: jest.fn(), // deprecated
22+
addEventListener: jest.fn(),
23+
removeEventListener: jest.fn(),
24+
dispatchEvent: jest.fn(),
25+
})),
26+
});
27+
1328
global.React = React;
1429

1530
const savedLocation = window.location;

0 commit comments

Comments
 (0)