Skip to content

Commit ea07233

Browse files
committed
Improve type safety in test setup mocks
1 parent e54609a commit ea07233

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/test/setup.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ const mockAudioContext = {
1919
suspend: vi.fn(),
2020
};
2121

22-
(global as any).AudioContext = vi
22+
(global as Record<string, unknown>).AudioContext = vi
2323
.fn()
2424
.mockImplementation(() => mockAudioContext);
25-
(global as any).webkitAudioContext = (global as any).AudioContext;
25+
(global as Record<string, unknown>).webkitAudioContext = (
26+
global as Record<string, unknown>
27+
).AudioContext;
2628

2729
// Mock other Web APIs that might be needed
28-
(global as any).HTMLMediaElement.prototype.play = vi.fn(() =>
29-
Promise.resolve(),
30-
);
31-
(global as any).HTMLMediaElement.prototype.pause = vi.fn();
30+
(
31+
global as Record<string, unknown> & {
32+
HTMLMediaElement: typeof HTMLMediaElement;
33+
}
34+
).HTMLMediaElement.prototype.play = vi.fn(() => Promise.resolve());
35+
(
36+
global as Record<string, unknown> & {
37+
HTMLMediaElement: typeof HTMLMediaElement;
38+
}
39+
).HTMLMediaElement.prototype.pause = vi.fn();
3240

3341
// Mock matchMedia for theme detection
3442
Object.defineProperty(window, "matchMedia", {

0 commit comments

Comments
 (0)