Skip to content

Commit c996cc4

Browse files
committed
hnnnggh
1 parent 8088719 commit c996cc4

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/svelte/tests/helpers.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,15 @@ export function write(file, contents) {
173173
fs.writeFileSync(file, contents);
174174
}
175175

176-
// @ts-expect-error JS DOM doesn't support it
177-
Window.prototype.matchMedia = (media) => {
178-
return {
179-
matches: false,
180-
media,
181-
addEventListener: () => {},
182-
removeEventListener: () => {}
176+
// Guard because not all test contexts load this with JSDOM
177+
if (typeof window !== 'undefined') {
178+
// @ts-expect-error JS DOM doesn't support it
179+
Window.prototype.matchMedia = (media) => {
180+
return {
181+
matches: false,
182+
media,
183+
addEventListener: () => {},
184+
removeEventListener: () => {}
185+
};
183186
};
184-
};
187+
}

0 commit comments

Comments
 (0)