Skip to content

Commit defa646

Browse files
committed
more tests fixes
1 parent 7c3fb02 commit defa646

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

packages/svelte/tests/helpers.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,13 @@ export function write(file, contents) {
172172

173173
fs.writeFileSync(file, contents);
174174
}
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: () => {}
183+
};
184+
};

packages/svelte/tests/motion/test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @vitest-environment jsdom
2+
import '../helpers.js'; // for the matchMedia polyfill
13
import { describe, it, assert } from 'vitest';
24
import { get } from 'svelte/store';
35
import { spring, tweened } from 'svelte/motion';

packages/svelte/tests/runtime-legacy/shared.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,3 @@ export function ok(value: any): asserts value {
478478
throw new Error(`Expected truthy value, got ${value}`);
479479
}
480480
}
481-
482-
// @ts-expect-error JS DOM doesn't support it
483-
Window.prototype.matchMedia = (media) => {
484-
return {
485-
matches: false,
486-
media,
487-
addEventListener: () => {},
488-
removeEventListener: () => {}
489-
};
490-
};

0 commit comments

Comments
 (0)