chore: Upgrade to Vitest 4 and regroup tests for performance (#2618)

This commit is contained in:
Dermot Duffy
2026-07-26 11:28:58 -07:00
committed by GitHub
parent a0fd464d23
commit 0c3d46ad3d
36 changed files with 1041 additions and 1207 deletions
@@ -32,7 +32,7 @@ describe('MP4StreamSource', () => {
const channel = new FakeStreamSourceChannel();
const loadedCallback = vi.fn();
const failedCallback = vi.fn();
const showFrame = vi.fn<[Blob], Promise<void>>(() => Promise.resolve());
const showFrame = vi.fn<(blob: Blob) => Promise<void>>(() => Promise.resolve());
const context: StreamSourceContext<ImageStreamTarget> = {
target: { kind: 'image', showFrame },
channel,
@@ -65,6 +65,7 @@ describe('MP4StreamSource', () => {
afterEach(() => {
vi.useRealTimers();
vi.restoreAllMocks();
});
it('should request the mp4 stream on start', () => {
@@ -217,6 +218,12 @@ describe('MP4StreamSource', () => {
callbacks: { loadedCallback: vi.fn(), failedCallback: vi.fn() },
});
// This is the only test that reaches a real canvas element. jsdom does not
// implement `getContext` and writes an error to the console when it is
// called; the source treats a missing context as nothing to draw to avoid
// console spam.
vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockReturnValue(null);
const createElement = vi.spyOn(document, 'createElement');
source.start();
channel.binaryCallback?.(frame());