🎥 Make videos programmatically with React
Use Bun to test core package
Jonny Burgercae9b5824aec
diff --git a/packages/core/happydom.ts b/packages/core/happydom.tsindex 081c9085a0..3194d2051d 100644--- a/packages/core/happydom.ts+++ b/packages/core/happydom.ts@@ -2,3 +2,5 @@ import {GlobalRegistrator} from '@happy-dom/global-registrator';GlobalRegistrator.register();window.origin = 'http://localhost:3000';+// @ts-expect-error+window.remotion_staticBase = '/static-abcdef';diff --git a/packages/core/package.json b/packages/core/package.jsonindex 807ab2756d..788efac9af 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -43,7 +43,6 @@"react-dom": "18.2.0","rimraf": "^3.0.2","rollup": "^2.70.1",- "vitest": "0.31.1","webpack": "5.83.1","zod": "3.22.3"},diff --git a/packages/core/src/CanUseRemotionHooks.tsx b/packages/core/src/CanUseRemotionHooks.tsxindex 158f8a336f..15c2822ba4 100644--- a/packages/core/src/CanUseRemotionHooks.tsx+++ b/packages/core/src/CanUseRemotionHooks.tsx@@ -3,7 +3,7 @@ import React, {createContext} from 'react';export const CanUseRemotionHooks = createContext<boolean>(false);export const CanUseRemotionHooksProvider: React.FC<{- children: React.ReactNode;+ readonly children: React.ReactNode;}> = ({children}) => {return (<CanUseRemotionHooks.Provider value>diff --git a/packages/core/src/audio/Audio.tsx b/packages/core/src/audio/Audio.tsxindex ce3eccc26c..b9d80ea44d 100644--- a/packages/core/src/audio/Audio.tsx+++ b/packages/core/src/audio/Audio.tsx@@ -24,7 +24,7 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction</*** @deprecated For internal use only*/- stack?: string;+ readonly stack?: string;}> = (props, ref) => {const audioContext = useContext(SharedAudioContext);diff --git a/packages/core/src/audio/AudioForRendering.tsx b/packages/core/src/audio/AudioForRendering.tsxindex ee566e37c8..72c2cbae1a 100644--- a/packages/core/src/audio/AudioForRendering.tsx+++ b/packages/core/src/audio/AudioForRendering.tsx@@ -20,7 +20,7 @@ import type {RemotionAudioProps} from './props.js';import {useFrameForVolumeProp} from './use-audio-frame.js';type AudioForRenderingProps = RemotionAudioProps & {- onDuration: (src: string, durationInSeconds: number) => void;+ readonly onDuration: (src: string, durationInSeconds: number) => void;};const AudioForRenderingRefForwardingFunction: React.ForwardRefRenderFunction<@@ -62,6 +62,7 @@ const AudioForRenderingRefForwardingFunction: React.ForwardRefRenderFunction<acceptableTimeShiftInSeconds,name,onError,+ pauseWhenBuffering,...nativeProps} = props;diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex dcf676e449..5307065896 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -23,7 +23,10 @@ declare global {interface Window {remotion_renderReady: boolean;remotion_delayRenderTimeouts: {- [key: string]: {label: string | null; timeout: number | NodeJS.Timeout};+ [key: string]: {+ label: string | null;+ timeout: number | NodeJS.Timeout | Timer;+ };};remotion_cancelledError: string | undefined;remotion_getCompositionNames: () => string[];diff --git a/packages/core/src/test/Img.test.tsx b/packages/core/src/test/Img.test.tsxindex fc01f0120e..980b45ae83 100644--- a/packages/core/src/test/Img.test.tsx+++ b/packages/core/src/test/Img.test.tsx@@ -1,9 +1,6 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';+import {beforeEach, expect, test} from 'bun:test';import React from 'react';-import {beforeEach, expect, test} from 'vitest';import {Img} from '../Img.js';const ref = React.createRef<HTMLImageElement>();diff --git a/packages/core/src/test/absolute-src.test.ts b/packages/core/src/test/absolute-src.test.tsindex 8fdc0ea433..df65c36260 100644--- a/packages/core/src/test/absolute-src.test.ts+++ b/packages/core/src/test/absolute-src.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {getAbsoluteSrc} from '../absolute-src.js';describe('Absolute src should behave as expected', () => {diff --git a/packages/core/src/test/audio-for-rendering.test.tsx b/packages/core/src/test/audio-for-rendering.test.tsxindex 0b2bb6b852..36fe96ae91 100644--- a/packages/core/src/test/audio-for-rendering.test.tsx+++ b/packages/core/src/test/audio-for-rendering.test.tsx@@ -1,16 +1,12 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';import {beforeEach, describe, expect, mock, test} from 'bun:test';import React from 'react';import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';-import {CompositionManager} from '../CompositionManagerContext.js';import {RenderAssetManager} from '../RenderAssetManager.js';import {ResolveCompositionConfig} from '../ResolveCompositionConfig.js';import {AudioForRendering} from '../audio/AudioForRendering.js';import {expectToThrow} from './expect-to-throw.js';-import {mockCompositionContext} from './wrap-sequence-context.js';+import {WrapSequenceContext} from './wrap-sequence-context.js';interface MockCompositionManagerContext {MockProvider: React.FC<{children: React.ReactNode}>;@@ -28,20 +24,18 @@ describe('Register and unregister asset', () => {readonly children: React.ReactNode;}> = ({children}) => {return (- <CanUseRemotionHooksProvider>- <CompositionManager.Provider value={mockCompositionContext}>- <RenderAssetManager.Provider- // eslint-disable-next-line react/jsx-no-constructed-context-values- value={{- registerRenderAsset,- unregisterRenderAsset,- renderAssets: [],- }}- >- <ResolveCompositionConfig>{children}</ResolveCompositionConfig>- </RenderAssetManager.Provider>- </CompositionManager.Provider>- </CanUseRemotionHooksProvider>+ <WrapSequenceContext>+ <RenderAssetManager.Provider+ // eslint-disable-next-line react/jsx-no-constructed-context-values+ value={{+ registerRenderAsset,+ unregisterRenderAsset,+ renderAssets: [],+ }}+ >+ <ResolveCompositionConfig>{children}</ResolveCompositionConfig>+ </RenderAssetManager.Provider>+ </WrapSequenceContext>);};diff --git a/packages/core/src/test/audio.test.tsx b/packages/core/src/test/audio.test.tsxindex 297bd6d41f..8eef8e1095 100644--- a/packages/core/src/test/audio.test.tsx+++ b/packages/core/src/test/audio.test.tsx@@ -1,8 +1,5 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {Audio} from '../audio/index.js';import {WrapSequenceContext} from './wrap-sequence-context.js';diff --git a/packages/core/src/test/bezier.test.ts b/packages/core/src/test/bezier.test.tsindex 701d4583f4..09f6af3fdd 100644--- a/packages/core/src/test/bezier.test.ts+++ b/packages/core/src/test/bezier.test.ts@@ -1,4 +1,4 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import {bezier} from '../bezier.js';const identity = (x: number) => {diff --git a/packages/core/src/test/composition-rules.test.tsx b/packages/core/src/test/composition-rules.test.tsxindex 149903760c..68068266f7 100644--- a/packages/core/src/test/composition-rules.test.tsx+++ b/packages/core/src/test/composition-rules.test.tsx@@ -1,9 +1,6 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';+import {describe, expect, test} from 'bun:test';import React from 'react';-import {describe, expect, test} from 'vitest';import {Composition} from '../Composition.js';import {RemotionRoot} from '../RemotionRoot.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/composition-validation.test.tsx b/packages/core/src/test/composition-validation.test.tsxindex 039cb11a2b..c451e27dc7 100644--- a/packages/core/src/test/composition-validation.test.tsx+++ b/packages/core/src/test/composition-validation.test.tsx@@ -1,9 +1,6 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';+import {describe, expect, test} from 'bun:test';import React from 'react';-import {describe, expect, test} from 'vitest';import {Composition} from '../Composition.js';import {resolveVideoConfig} from '../resolve-video-config.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/easing.test.ts b/packages/core/src/test/easing.test.tsindex 80e420c36e..1eebe3a4d3 100644--- a/packages/core/src/test/easing.test.ts+++ b/packages/core/src/test/easing.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {Easing} from '../easing.js';const numbersToTest = [-0.5, 0, 0.4, 0.5, 0.7, 1, 1.5];diff --git a/packages/core/src/test/freeze.test.tsx b/packages/core/src/test/freeze.test.tsxindex 81c921a6d4..228769347e 100644--- a/packages/core/src/test/freeze.test.tsx+++ b/packages/core/src/test/freeze.test.tsx@@ -1,9 +1,6 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';+import {describe, expect, test} from 'bun:test';import React from 'react';-import {describe, expect, test} from 'vitest';import {Sequence} from '../Sequence.js';import {Freeze} from '../freeze.js';import type {TimelineContextValue} from '../timeline-position-state.js';diff --git a/packages/core/src/test/get-asset-file-name.test.ts b/packages/core/src/test/get-asset-file-name.test.tsindex f955f02523..2f0c7eccf3 100644--- a/packages/core/src/test/get-asset-file-name.test.ts+++ b/packages/core/src/test/get-asset-file-name.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {getAssetDisplayName} from '../get-asset-file-name.js';describe('get asset file name test', () => {diff --git a/packages/core/src/test/get-current-time.test.ts b/packages/core/src/test/get-current-time.test.tsindex f056903234..32df60331c 100644--- a/packages/core/src/test/get-current-time.test.ts+++ b/packages/core/src/test/get-current-time.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {getMediaTime} from '../video/get-current-time.js';describe('correctly calculate media time of video element', () => {diff --git a/packages/core/src/test/includes-hex-of-unsafe-char.test.ts b/packages/core/src/test/includes-hex-of-unsafe-char.test.tsindex 5fa1d13a4c..8375d662e0 100644--- a/packages/core/src/test/includes-hex-of-unsafe-char.test.ts+++ b/packages/core/src/test/includes-hex-of-unsafe-char.test.ts@@ -1,4 +1,4 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import type {HexInfo} from '../static-file.js';import {includesHexOfUnsafeChar} from '../static-file.js';diff --git a/packages/core/src/test/input-props.test.ts b/packages/core/src/test/input-props.test.tsindex ccfa447663..92aa0f3476 100644--- a/packages/core/src/test/input-props.test.ts+++ b/packages/core/src/test/input-props.test.ts@@ -1,14 +1,10 @@-/**- * @vitest-environment jsdom- */-import {afterAll, beforeEach, describe, expect, test, vitest} from 'vitest';+import {afterAll, beforeEach, describe, expect, test} from 'bun:test';import {getInputProps} from '../config/input-props.js';describe('input props', () => {const OLD_ENV = process.env;beforeEach(() => {- vitest.resetModules(); // Most important - it clears the cacheprocess.env = {...OLD_ENV}; // Make a copy});@@ -24,7 +20,9 @@ describe('input props', () => {};window.remotion_inputProps = JSON.stringify(JSON.stringify(inputProps));- expect(getInputProps()).toEqual(JSON.stringify(inputProps));+ expect(getInputProps()).toEqual(+ JSON.stringify(inputProps) as unknown as Record<string, unknown>,+ );});test('input props in production env', () => {diff --git a/packages/core/src/test/interpolate.test.ts b/packages/core/src/test/interpolate.test.tsindex 32e776d03d..cf4a0e2c72 100644--- a/packages/core/src/test/interpolate.test.ts+++ b/packages/core/src/test/interpolate.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {Easing} from '../easing.js';import {interpolate} from '../interpolate.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/interpolateColors.test.ts b/packages/core/src/test/interpolateColors.test.tsindex 46707fc8db..e6eed9c79d 100644--- a/packages/core/src/test/interpolateColors.test.ts+++ b/packages/core/src/test/interpolateColors.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {interpolateColors} from '../interpolate-colors.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/json-serialization.test.ts b/packages/core/src/test/json-serialization.test.tsindex aa204a7406..2fed6ccabb 100644--- a/packages/core/src/test/json-serialization.test.ts+++ b/packages/core/src/test/json-serialization.test.ts@@ -1,4 +1,4 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import {deserializeJSONWithCustomFields,serializeJSONWithDate,diff --git a/packages/core/src/test/loop-validation.test.tsx b/packages/core/src/test/loop-validation.test.tsxindex a7dabc6c14..8acfeb4adb 100644--- a/packages/core/src/test/loop-validation.test.tsx+++ b/packages/core/src/test/loop-validation.test.tsx@@ -1,9 +1,6 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';+import {describe, expect, test} from 'bun:test';import {renderToString} from 'react-dom/server';-import {describe, expect, test} from 'vitest';import {Loop} from '../loop/index.js';import {expectToThrow} from './expect-to-throw.js';import {WrapSequenceContext} from './wrap-sequence-context.js';diff --git a/packages/core/src/test/measure-spring.test.ts b/packages/core/src/test/measure-spring.test.tsindex d8b99985bf..a6b2bd95b3 100644--- a/packages/core/src/test/measure-spring.test.ts+++ b/packages/core/src/test/measure-spring.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {measureSpring, spring} from '../spring/index.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/media-validation.test.tsx b/packages/core/src/test/media-validation.test.tsxindex babbde11d0..9d3808e230 100644--- a/packages/core/src/test/media-validation.test.tsx+++ b/packages/core/src/test/media-validation.test.tsx@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {validateMediaProps} from '../validate-media-props.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/nested-sequences.test.tsx b/packages/core/src/test/nested-sequences.test.tsxindex 7dd921fb5d..71337057aa 100644--- a/packages/core/src/test/nested-sequences.test.tsx+++ b/packages/core/src/test/nested-sequences.test.tsx@@ -1,9 +1,6 @@-/**- * @vitest-environment jsdom- *//* eslint-disable react/jsx-no-constructed-context-values */import {cleanup, render} from '@testing-library/react';-import {afterEach, expect, test} from 'vitest';+import {afterEach, expect, test} from 'bun:test';import {AbsoluteFill} from '../AbsoluteFill.js';import {Sequence} from '../Sequence.js';import {TimelineContext} from '../timeline-position-state.js';diff --git a/packages/core/src/test/not-all-props-in-media-tags.test.ts b/packages/core/src/test/not-all-props-in-media-tags.test.tsindex cbe3873bcb..ca509fd048 100644--- a/packages/core/src/test/not-all-props-in-media-tags.test.ts+++ b/packages/core/src/test/not-all-props-in-media-tags.test.ts@@ -1,6 +1,6 @@+import {expect, test} from 'bun:test';import fs from 'node:fs';import path from 'node:path';-import {expect, test} from 'vitest';// Test for https://github.com/remotion-dev/remotion/issues/1243test('Should not have disableRemotePlayback props in the <VideoForPreview> component type definition', () => {diff --git a/packages/core/src/test/offthread-props.test.tsx b/packages/core/src/test/offthread-props.test.tsxindex fe95b0542e..bc773b0410 100644--- a/packages/core/src/test/offthread-props.test.tsx+++ b/packages/core/src/test/offthread-props.test.tsx@@ -1,5 +1,5 @@+import {expect, test} from 'bun:test';import {renderToString} from 'react-dom/server';-import {expect, test} from 'vitest';import {OffthreadVideo} from '../video/index.js';test('Passing imageFormat to OffthreadVideo should throw error', () => {diff --git a/packages/core/src/test/random.test.ts b/packages/core/src/test/random.test.tsindex 00658c5a89..d4c7ea6f92 100644--- a/packages/core/src/test/random.test.ts+++ b/packages/core/src/test/random.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {random} from '../random.js';describe('Should support negative random numbers', () => {diff --git a/packages/core/src/test/ready-manager.test.ts b/packages/core/src/test/ready-manager.test.tsindex 591855c93a..a69725317f 100644--- a/packages/core/src/test/ready-manager.test.ts+++ b/packages/core/src/test/ready-manager.test.ts@@ -1,7 +1,4 @@-/**- * @vitest-environment jsdom- */-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {continueRender, delayRender} from '../delay-render.js';describe('Ready Manager tests', () => {diff --git a/packages/core/src/test/sequence-from-initial-offset.test.tsx b/packages/core/src/test/sequence-from-initial-offset.test.tsxindex b28223c0c9..d1421ef315 100644--- a/packages/core/src/test/sequence-from-initial-offset.test.tsx+++ b/packages/core/src/test/sequence-from-initial-offset.test.tsx@@ -1,15 +1,8 @@-/**- * @vitest-environment jsdom- */-import {render} from '@testing-library/react';+import {describe, expect, test} from 'bun:test';import React from 'react';-import {describe, expect, test} from 'vitest';-import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';import {Sequence} from '../Sequence.js';import {Freeze} from '../freeze.js';-import type {TimelineContextValue} from '../timeline-position-state.js';-import {TimelineContext} from '../timeline-position-state.js';import {useVideoConfig} from '../use-video-config.js';import {WrapSequenceContext} from './wrap-sequence-context.js';@@ -19,34 +12,16 @@ const Inner: React.FC = () => {return <div>{config.durationInFrames}</div>;};-const context: TimelineContextValue = {- audioAndVideoTags: {current: []},- frame: {- 'my-comp': 100000,- },- imperativePlaying: {- current: false,- },- playbackRate: 0,- playing: false,- rootId: 'hither',- setPlaybackRate: () => undefined,-};-describe('Composition-validation render should NOT throw with valid props', () => {test('It should allow undefined as children', () => {const {queryByText} = render(- <CanUseRemotionHooksProvider>- <WrapSequenceContext>- <TimelineContext.Provider value={context}>- <Freeze frame={10000}>- <Sequence durationInFrames={2424} from={9265}>- <Inner />- </Sequence>- </Freeze>- </TimelineContext.Provider>- </WrapSequenceContext>- </CanUseRemotionHooksProvider>,+ <WrapSequenceContext>+ <Freeze frame={10000}>+ <Sequence durationInFrames={2424} from={9265}>+ <Inner />+ </Sequence>+ </Freeze>+ </WrapSequenceContext>,);expect(queryByText(/^2424$/)).not.toBe(null);diff --git a/packages/core/src/test/sequence-validation.test.tsx b/packages/core/src/test/sequence-validation.test.tsxindex 6124c47e64..c1f911b2b5 100644--- a/packages/core/src/test/sequence-validation.test.tsx+++ b/packages/core/src/test/sequence-validation.test.tsx@@ -1,10 +1,6 @@-/**- * @vitest-environment jsdom- */import {render} from '@testing-library/react';+import {describe, expect, test} from 'bun:test';import {renderToString} from 'react-dom/server';-import {describe, expect, test} from 'vitest';-import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';import {Sequence} from '../Sequence.js';import {expectToThrow} from './expect-to-throw.js';import {WrapSequenceContext} from './wrap-sequence-context.js';@@ -14,13 +10,11 @@ describe('Composition-validation render should throw with invalid props', () =>test('It should throw if Sequence has non-integer durationInFrames', () => {expect(renderToString(- <CanUseRemotionHooksProvider>- <WrapSequenceContext>- <Sequence from={0} durationInFrames={1.1}>- hi- </Sequence>- </WrapSequenceContext>- </CanUseRemotionHooksProvider>,+ <WrapSequenceContext>+ <Sequence from={0} durationInFrames={1.1}>+ hi+ </Sequence>+ </WrapSequenceContext>,),).toBe('<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex">hi</div>',@@ -60,26 +54,22 @@ describe('Composition-validation render should NOT throw with valid props', () =test('It should allow null as children', () => {expect(() =>render(- <CanUseRemotionHooksProvider>- <WrapSequenceContext>- <Sequence durationInFrames={100} from={0}>- {null}- </Sequence>- </WrapSequenceContext>- </CanUseRemotionHooksProvider>,+ <WrapSequenceContext>+ <Sequence durationInFrames={100} from={0}>+ {null}+ </Sequence>+ </WrapSequenceContext>,),).not.toThrow();});test('It should allow undefined as children', () => {expect(() =>render(- <CanUseRemotionHooksProvider>- <WrapSequenceContext>- <Sequence durationInFrames={100} from={0}>- {undefined}- </Sequence>- </WrapSequenceContext>- </CanUseRemotionHooksProvider>,+ <WrapSequenceContext>+ <Sequence durationInFrames={100} from={0}>+ {undefined}+ </Sequence>+ </WrapSequenceContext>,),).not.toThrow();});diff --git a/packages/core/src/test/series.test.tsx b/packages/core/src/test/series.test.tsxindex 5761d39a05..6cbb634c19 100644--- a/packages/core/src/test/series.test.tsx+++ b/packages/core/src/test/series.test.tsx@@ -1,10 +1,7 @@-/**- * @vitest-environment jsdom- *//* eslint-disable react/jsx-no-constructed-context-values */+import {expect, test} from 'bun:test';import React from 'react';import {renderToString} from 'react-dom/server';-import {expect, test} from 'vitest';import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';import {Series} from '../series/index.js';import {TimelineContext} from '../timeline-position-state.js';diff --git a/packages/core/src/test/spring-bench.test.ts b/packages/core/src/test/spring-bench.test.tsindex a566074467..27e89ef560 100644--- a/packages/core/src/test/spring-bench.test.ts+++ b/packages/core/src/test/spring-bench.test.ts@@ -1,4 +1,4 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import {spring} from '../spring';test('Springs should calculate fast and cache the natural duration', async () => {diff --git a/packages/core/src/test/static-file-errors.test.ts b/packages/core/src/test/static-file-errors.test.tsindex 75e2ded83e..e840878358 100644--- a/packages/core/src/test/static-file-errors.test.ts+++ b/packages/core/src/test/static-file-errors.test.ts@@ -1,11 +1,7 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import {staticFile} from '../static-file.js';test('duplicate staticFile() should throw a warning', () => {- // @ts-expect-error- global.window = {- remotion_staticBase: '/static-abcdef',- };expect(() => staticFile(staticFile('file.mp3'))).toThrow('The value "/static-abcdef/file.mp3" is already prefixed with the static base /static-abcdef. You don\'t need to call staticFile() on it.',);diff --git a/packages/core/src/test/static-file-safe-uri.test.ts b/packages/core/src/test/static-file-safe-uri.test.tsindex f0833bfc5f..941057a552 100644--- a/packages/core/src/test/static-file-safe-uri.test.ts+++ b/packages/core/src/test/static-file-safe-uri.test.ts@@ -1,32 +1,36 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import {staticFile} from '../static-file.js';test('staticFile() should convert # into %23', () => {const unsafeName = 'test/example#music';- expect(staticFile(unsafeName)).toBe('/test/example%23music');+ expect(staticFile(unsafeName)).toBe('/static-abcdef/test/example%23music');});test('staticFile() passing already encoded path should give warning', () => {const unsafeName = '/test%2Fexample%23music';- expect(staticFile(unsafeName)).toBe('/test%252Fexample%2523music');+ expect(staticFile(unsafeName)).toBe(+ '/static-abcdef/test%252Fexample%2523music',+ );});test('staticFile() should not encode slashes', () => {const nameWithSlashes = '/test/example/word';- expect(staticFile(nameWithSlashes)).toBe(nameWithSlashes);+ expect(staticFile(nameWithSlashes)).toBe(`/static-abcdef${nameWithSlashes}`);});test('staticFile() should encode all problematic characters except slashes', () => {const nameWithSlashes = '/test/#example/$word';- expect(staticFile(nameWithSlashes)).toBe('/test/%23example/%24word');+ expect(staticFile(nameWithSlashes)).toBe(+ '/static-abcdef/test/%23example/%24word',+ );});test('if no leading slash exists, one should be added', () => {const nameWithSlashes = 'test/example';- expect(staticFile(nameWithSlashes)).toBe('/test/example');+ expect(staticFile(nameWithSlashes)).toBe('/static-abcdef/test/example');});test('problematic character at the beginning should be encoded correctly', () => {const problematicStart = '#test/example';- expect(staticFile(problematicStart)).toBe('/%23test/example');+ expect(staticFile(problematicStart)).toBe('/static-abcdef/%23test/example');});diff --git a/packages/core/src/test/truthy.test.ts b/packages/core/src/test/truthy.test.tsindex f256ab7b03..17c12dd219 100644--- a/packages/core/src/test/truthy.test.ts+++ b/packages/core/src/test/truthy.test.ts@@ -1,4 +1,4 @@-import {expect, test} from 'vitest';+import {expect, test} from 'bun:test';import {truthy} from '../truthy.js';test.each<[unknown, boolean]>([diff --git a/packages/core/src/test/use-media-in-timeline.test.tsx b/packages/core/src/test/use-media-in-timeline.test.tsxindex f4af85f741..1d6826f13f 100644--- a/packages/core/src/test/use-media-in-timeline.test.tsx+++ b/packages/core/src/test/use-media-in-timeline.test.tsx@@ -1,35 +1,12 @@-/**- * @vitest-environment jsdom- */-import {afterAll, beforeAll, expect, mock, spyOn, test} from 'bun:test';+import {expect, mock, test} from 'bun:test';import type {RefObject} from 'react';import React, {useMemo} from 'react';-import {CompositionManager} from '../CompositionManagerContext.js';-import {RenderAssetManagerProvider} from '../RenderAssetManager.js';import {ResolveCompositionConfig} from '../ResolveCompositionConfig.js';import type {SequenceManagerContext} from '../SequenceManager.js';import {SequenceManager} from '../SequenceManager.js';import {useMediaInTimeline} from '../use-media-in-timeline.js';-import * as useVideoConfigModule from '../use-video-config.js';import {renderHook} from './render-hook.js';-import {mockCompositionContext} from './wrap-sequence-context.js';--beforeAll(() => {- spyOn(useVideoConfigModule, 'useVideoConfig').mockImplementation(() => ({- width: 10,- height: 10,- fps: 30,- durationInFrames: 100,- id: 'hithere',- defaultProps: {},- props: {},- defaultCodec: null,- }));-});--afterAll(() => {- spyOn(useVideoConfigModule, 'useVideoConfig').mockClear();-});+import {WrapSequenceContext} from './wrap-sequence-context.js';test('useMediaInTimeline registers and unregisters new sequence', () => {const registerSequence = mock();@@ -47,13 +24,11 @@ test('useMediaInTimeline registers and unregisters new sequence', () => {}, []);return (- <CompositionManager.Provider value={mockCompositionContext}>+ <WrapSequenceContext><SequenceManager.Provider value={sequenceManagerContext}>- <RenderAssetManagerProvider>- <ResolveCompositionConfig>{children}</ResolveCompositionConfig>- </RenderAssetManagerProvider>+ <ResolveCompositionConfig>{children}</ResolveCompositionConfig></SequenceManager.Provider>- </CompositionManager.Provider>+ </WrapSequenceContext>);};diff --git a/packages/core/src/test/use-media-tag-volume.test.tsx b/packages/core/src/test/use-media-tag-volume.test.tsxindex 4196e248f7..cd5a01b1b3 100644--- a/packages/core/src/test/use-media-tag-volume.test.tsx+++ b/packages/core/src/test/use-media-tag-volume.test.tsx@@ -1,54 +1,11 @@-/**- * @vitest-environment jsdom- */+import {expect, mock, test} from 'bun:test';import type {RefObject} from 'react';-import React from 'react';-import {afterEach, beforeEach, describe, expect, test, vitest} from 'vitest';import {useMediaTagVolume} from '../use-media-tag-volume.js';import {renderHook} from './render-hook.js';-describe('Should update state when volume changes', () => {- const setState = vitest.fn();- const useStateSpy = vitest.spyOn(React, 'useState');- beforeEach(() => {- // @ts-expect-error- useStateSpy.mockImplementation((init) => [init, setState]);- });- afterEach(() => {- useStateSpy.mockRestore();- });-- test.skip('has the volume been set', () => {- const addEventListener = vitest.fn();- const removeEventListener = vitest.fn();- let audioRef = {- current: {volume: 0.5, addEventListener, removeEventListener},- } as unknown as RefObject<HTMLAudioElement>;-- const {rerender} = renderHook(({mediaRef}) => useMediaTagVolume(mediaRef), {- initialProps: {mediaRef: audioRef},- });-- expect(setState).toHaveBeenCalledWith(0.5);- audioRef = {- current: {...audioRef.current, volume: 0.75},- } as RefObject<HTMLAudioElement>;- rerender({mediaRef: audioRef});- expect(setState).toHaveBeenCalledWith(0.75);- expect(addEventListener).toHaveBeenCalledWith(- 'volumechange',- expect.anything(),- );- expect(removeEventListener).toHaveBeenCalledWith(- 'volumechange',- expect.anything(),- );- });-});-test('Should listen for volume changes', () => {- const addEventListener = vitest.fn();- const removeEventListener = vitest.fn();+ const addEventListener = mock();+ const removeEventListener = mock();const audioRef = {current: {volume: 0.5, addEventListener, removeEventListener},} as unknown as RefObject<HTMLAudioElement>;diff --git a/packages/core/src/test/use-sync-volume-with-media-tag.test.ts b/packages/core/src/test/use-sync-volume-with-media-tag.test.tsindex 5d60dea4cd..e71cab839a 100644--- a/packages/core/src/test/use-sync-volume-with-media-tag.test.ts+++ b/packages/core/src/test/use-sync-volume-with-media-tag.test.ts@@ -1,16 +1,13 @@-/**- * @vitest-environment jsdom- */+import {expect, mock, test} from 'bun:test';import type {RefObject} from 'react';-import {expect, test, vitest} from 'vitest';import type {UseSyncVolumeWithMediaTagOptions} from '../use-sync-volume-with-media-tag.js';import {useSyncVolumeWithMediaTag} from '../use-sync-volume-with-media-tag.js';import type {VolumeProp} from '../volume-prop.js';import {renderHook} from './render-hook.js';test('has the volume been adapted', () => {- const addEventListener = vitest.fn();- const removeEventListener = vitest.fn();+ const addEventListener = mock();+ const removeEventListener = mock();const audioRef = {current: {volume: 0.5, addEventListener, removeEventListener},} as unknown as RefObject<HTMLAudioElement>;@@ -32,7 +29,7 @@ test('has the volume been adapted', () => {initialProps,},);- expect(audioRef.current?.volume).toEqual(initialProps.volume);+ expect(audioRef.current?.volume).toEqual(initialProps.volume as number);const newVolume = 0.5;rerender({...initialProps,@@ -42,8 +39,8 @@ test('has the volume been adapted', () => {});test('volume should not be adapted', () => {- const addEventListener = vitest.fn();- const removeEventListener = vitest.fn();+ const addEventListener = mock();+ const removeEventListener = mock();const audioRef = {current: {volume: 0.4, addEventListener, removeEventListener},} as unknown as RefObject<HTMLAudioElement>;@@ -62,5 +59,5 @@ test('volume should not be adapted', () => {renderHook((hookProps) => useSyncVolumeWithMediaTag(hookProps), {initialProps,});- expect(audioRef.current?.volume).toEqual(initialProps.volume);+ expect(audioRef.current?.volume).toEqual(initialProps.volume as number);});diff --git a/packages/core/src/test/validate-start-from-props.test.ts b/packages/core/src/test/validate-start-from-props.test.tsindex 30b835b5e4..ca393fe405 100644--- a/packages/core/src/test/validate-start-from-props.test.ts+++ b/packages/core/src/test/validate-start-from-props.test.ts@@ -1,4 +1,4 @@-import {describe, test} from 'vitest';+import {describe, test} from 'bun:test';import {validateStartFromProps} from '../validate-start-from-props.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/video.test.tsx b/packages/core/src/test/video.test.tsxindex f4e37cbaed..d27bb975d0 100644--- a/packages/core/src/test/video.test.tsx+++ b/packages/core/src/test/video.test.tsx@@ -1,6 +1,5 @@import {render} from '@testing-library/react';-import {describe, expect, test} from 'vitest';-import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';+import {describe, expect, test} from 'bun:test';import {Video} from '../video/index.js';import {expectToThrow} from './expect-to-throw.js';import {WrapSequenceContext} from './wrap-sequence-context.js';@@ -44,12 +43,7 @@ describe('Render correctly with props', () => {});test('It should throw if videoConfig/Wrapper is missing', () => {expectToThrow(- () =>- render(- <CanUseRemotionHooksProvider>- <Video startFrom={10} endAt={15} />- </CanUseRemotionHooksProvider>,- ),+ () => render(<Video startFrom={10} endAt={15} />),/No video config found/,);});diff --git a/packages/core/src/test/volume-prop.test.ts b/packages/core/src/test/volume-prop.test.tsindex 2eec01fcab..290daf9d93 100644--- a/packages/core/src/test/volume-prop.test.ts+++ b/packages/core/src/test/volume-prop.test.ts@@ -1,4 +1,4 @@-import {describe, expect, test} from 'vitest';+import {describe, expect, test} from 'bun:test';import {evaluateVolume} from '../volume-prop.js';import {expectToThrow} from './expect-to-throw.js';diff --git a/packages/core/src/test/wrap-sequence-context.tsx b/packages/core/src/test/wrap-sequence-context.tsxindex b43e671f21..4a9aae0102 100644--- a/packages/core/src/test/wrap-sequence-context.tsx+++ b/packages/core/src/test/wrap-sequence-context.tsx@@ -6,7 +6,7 @@ import {ResolveCompositionConfig} from '../ResolveCompositionConfig.js';const Comp: React.FC = () => null;-export const mockCompositionContext: CompositionManagerContext = {+const mockCompositionContext: CompositionManagerContext = {assets: [],compositions: [{@@ -33,7 +33,7 @@ export const mockCompositionContext: CompositionManagerContext = {};export const WrapSequenceContext: React.FC<{- children: React.ReactNode;+ readonly children: React.ReactNode;}> = ({children}) => {return (<CanUseRemotionHooksProvider>