We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8088719 commit c996cc4Copy full SHA for c996cc4
packages/svelte/tests/helpers.js
@@ -173,12 +173,15 @@ export function write(file, contents) {
173
fs.writeFileSync(file, contents);
174
}
175
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: () => {}
+// Guard because not all test contexts load this with JSDOM
+if (typeof window !== 'undefined') {
+ // @ts-expect-error JS DOM doesn't support it
+ Window.prototype.matchMedia = (media) => {
+ return {
+ matches: false,
+ media,
183
+ addEventListener: () => {},
184
+ removeEventListener: () => {}
185
+ };
186
};
-};
187
+}
0 commit comments