🎥 Make videos programmatically with React
retry flaky tests
Jonny Burger713cc9fabacf
diff --git a/packages/example/src/test/stills.test.ts b/packages/example/src/test/stills.test.tsindex 19ac313bc1..f9c470ff39 100644--- a/packages/example/src/test/stills.test.ts+++ b/packages/example/src/test/stills.test.ts@@ -11,73 +11,80 @@ import {TCompMetadata} from 'remotion';import {expect, test} from 'vitest';import {webpackOverride} from '../webpack-override';-test('Can render a still using Node.JS APIs', async () => {- const bundled = await bundle({- entryPoint: path.join(process.cwd(), 'src/index.tsx'),- webpackOverride,- });+test(+ 'Can render a still using Node.JS APIs',+ async () => {+ const bundled = await bundle({+ entryPoint: path.join(process.cwd(), 'src/index.tsx'),+ webpackOverride,+ });- const compositions = await getCompositions(bundled);+ const compositions = await getCompositions(bundled);- const composition = compositions.find(- (c) => c.id === 'react-svg'- ) as TCompMetadata;+ const composition = compositions.find(+ (c) => c.id === 'react-svg'+ ) as TCompMetadata;- const testOut = path.join(tmpdir(), 'path/to/still.png');+ const testOut = path.join(tmpdir(), 'path/to/still.png');- const {port, close} = await RenderInternals.serveStatic(bundled, {- onDownload: () => undefined,- port: null,- onError: (err) => {- throw err;- },- ffmpegExecutable: null,- ffprobeExecutable: null,- downloadMap: RenderInternals.makeDownloadMap(),- });+ const {port, close} = await RenderInternals.serveStatic(bundled, {+ onDownload: () => undefined,+ port: null,+ onError: (err) => {+ throw err;+ },+ ffmpegExecutable: null,+ ffprobeExecutable: null,+ downloadMap: RenderInternals.makeDownloadMap(),+ });- const serveUrl = `http://localhost:${port}`;- const fileOSRoot = path.parse(__dirname).root;+ const serveUrl = `http://localhost:${port}`;+ const fileOSRoot = path.parse(__dirname).root;- expect(() =>- renderStill({- composition,- output: testOut,- serveUrl,- frame: 500,- })- ).rejects.toThrow(- /Cannot use frame 500: Duration of composition is 300, therefore the highest frame that can be rendered is 299/- );+ expect(() =>+ renderStill({+ composition,+ output: testOut,+ serveUrl,+ frame: 500,+ })+ ).rejects.toThrow(+ /Cannot use frame 500: Duration of composition is 300, therefore the highest frame that can be rendered is 299/+ );- expect(() =>- renderStill({- composition,- output: process.platform === 'win32' ? fileOSRoot : '/var',- serveUrl,- })- ).rejects.toThrow(/already exists, but is not a file/);+ expect(() =>+ renderStill({+ composition,+ output: process.platform === 'win32' ? fileOSRoot : '/var',+ serveUrl,+ })+ ).rejects.toThrow(/already exists, but is not a file/);++ expect(() =>+ renderStill({+ composition,+ output: 'src/index.tsx',+ serveUrl,+ overwrite: false,+ })+ ).rejects.toThrow(+ /Cannot render still - "overwrite" option was set to false, but the output/+ );- expect(() =>- renderStill({+ await renderStill({composition,- output: 'src/index.tsx',+ output: testOut,serveUrl,- overwrite: false,- })- ).rejects.toThrow(- /Cannot render still - "overwrite" option was set to false, but the output/- );-- await renderStill({- composition,- output: testOut,- serveUrl,- frame: 100,- });+ frame: 100,+ });- expect(existsSync(testOut)).toBe(true);- unlinkSync(testOut);+ expect(existsSync(testOut)).toBe(true);+ unlinkSync(testOut);- await close();-}, 90000);+ await close();+ },+ {+ retry: 3,+ timeout: 90000,+ }+);diff --git a/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts b/packages/it-tests/src/rendering/frame-accuracy-gif.test.tsindex 95a1f1ab49..94b7ed8d8a 100644--- a/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts+++ b/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts@@ -92,4 +92,6 @@ const getMissedFramesforCodec = async () => {test("should render correct frames from embedded videos - MP4 offthread", async () => {const missedFrames = await getMissedFramesforCodec();expect(missedFrames).toBe(0);+}, {+ retry: 2});diff --git a/packages/it-tests/src/rendering/frame-accuracy-video.test.ts b/packages/it-tests/src/rendering/frame-accuracy-video.test.tsindex 1abf7a80cf..32f37f8428 100644--- a/packages/it-tests/src/rendering/frame-accuracy-video.test.ts+++ b/packages/it-tests/src/rendering/frame-accuracy-video.test.ts@@ -89,4 +89,6 @@ const getMissedFramesforCodec = async () => {test("should render correct frames from embedded videos - MP4 offthread", async () => {const missedFrames = await getMissedFramesforCodec();expect(missedFrames).toBe(0);+}, {+ retry: 2});diff --git a/packages/it-tests/src/rendering/frame-accuracy.test.ts b/packages/it-tests/src/rendering/frame-accuracy.test.tsindex d7cb93a4ed..edb5163cbe 100644--- a/packages/it-tests/src/rendering/frame-accuracy.test.ts+++ b/packages/it-tests/src/rendering/frame-accuracy.test.ts@@ -88,18 +88,27 @@ const getMissedFramesforCodec = async (test("should render correct frames from embedded videos - WebM onthread", async () => {const missedFrames = await getMissedFramesforCodec("webm", false);expect(missedFrames).toBeLessThanOrEqual(1);+}, {+ retry: 2});+test("should render correct frames from embedded videos - WebM offthread", async () => {const missedFrames = await getMissedFramesforCodec("webm", true);expect(missedFrames).toBe(0);+}, {+ retry: 2});test("should render correct frames from embedded videos - MP4 onthread", async () => {const missedFrames = await getMissedFramesforCodec("mp4", false);expect(missedFrames).toBeLessThanOrEqual(1);+}, {+ retry: 2});test("should render correct frames from embedded videos - MP4 offthread", async () => {const missedFrames = await getMissedFramesforCodec("mp4", true);expect(missedFrames).toBe(0);+}, {+ retry: 2});diff --git a/packages/noise/src/test/noise-cache.test.ts b/packages/noise/src/test/noise-cache.test.tsindex 93f438d4fe..2fac8428fb 100644--- a/packages/noise/src/test/noise-cache.test.ts+++ b/packages/noise/src/test/noise-cache.test.ts@@ -7,101 +7,125 @@ if (typeof performance === 'undefined') {expect(1).toBe(1);});} else {- test('Noise should be deterministic', () => {- const noise1 = noise2D(1, 0, 0);- const noise2 = noise2D(1, 0, 0);- expect(noise1).toBe(noise2);- expect(noise1).toBe(0);- expect(noise2D('my-seed', 0.5, 0.5)).toBe(0.3071565136272162);- expect(noise3D('my-seed', 0.7, 0.5, 0.5)).toBe(0.6402128434567901);- expect(noise4D('my-seed', 0.7, 0.5, 0.5, 0.9)).toBe(0.2714290963058814);- });+ test(+ 'Noise should be deterministic',+ () => {+ const noise1 = noise2D(1, 0, 0);+ const noise2 = noise2D(1, 0, 0);+ expect(noise1).toBe(noise2);+ expect(noise1).toBe(0);+ expect(noise2D('my-seed', 0.5, 0.5)).toBe(0.3071565136272162);+ expect(noise3D('my-seed', 0.7, 0.5, 0.5)).toBe(0.6402128434567901);+ expect(noise4D('my-seed', 0.7, 0.5, 0.5, 0.9)).toBe(0.2714290963058814);+ },+ {retry: 2}+ );- test('Noise should be cached', () => {- const start = performance.now();- noise2D('new-seed', 0.5, 0.5);- const end = performance.now();- const time = end - start;+ test(+ 'Noise should be cached',+ () => {+ const start = performance.now();+ noise2D('new-seed', 0.5, 0.5);+ const end = performance.now();+ const time = end - start;- const start2 = performance.now();- noise2D('new-seed', 0.5, 0.5);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 10).toBeLessThan(time);- });+ const start2 = performance.now();+ noise2D('new-seed', 0.5, 0.5);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 10).toBeLessThan(time);+ },+ {retry: 2}+ );- test('Should only keep 10 cache entries', () => {- const start = performance.now();- noise2D('seed-1', 0.5, 0.5);- const end = performance.now();- const time = end - start;+ test(+ 'Should only keep 10 cache entries',+ () => {+ const start = performance.now();+ noise2D('seed-1', 0.5, 0.5);+ const end = performance.now();+ const time = end - start;- noise2D('seed-2', 0.5, 0.5);- noise2D('seed-3', 0.5, 0.5);- noise2D('seed-4', 0.5, 0.5);- noise2D('seed-5', 0.5, 0.5);- noise2D('seed-6', 0.5, 0.5);- noise2D('seed-7', 0.5, 0.5);- noise2D('seed-8', 0.5, 0.5);- noise2D('seed-9', 0.5, 0.5);- noise2D('seed-10', 0.5, 0.5);- noise2D('seed-11', 0.5, 0.5);- noise2D('seed-12', 0.5, 0.5);+ noise2D('seed-2', 0.5, 0.5);+ noise2D('seed-3', 0.5, 0.5);+ noise2D('seed-4', 0.5, 0.5);+ noise2D('seed-5', 0.5, 0.5);+ noise2D('seed-6', 0.5, 0.5);+ noise2D('seed-7', 0.5, 0.5);+ noise2D('seed-8', 0.5, 0.5);+ noise2D('seed-9', 0.5, 0.5);+ noise2D('seed-10', 0.5, 0.5);+ noise2D('seed-11', 0.5, 0.5);+ noise2D('seed-12', 0.5, 0.5);- const start2 = performance.now();- noise2D('seed-1', 0.5, 0.5);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 4).toBeGreaterThan(time);- });+ const start2 = performance.now();+ noise2D('seed-1', 0.5, 0.5);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 4).toBeGreaterThan(time);+ },+ {+ retry: 2,+ }+ );- test('Should only keep 10 cache entries (3D)', () => {- const start = performance.now();- noise3D('seed-1', 0.5, 0.5, 0.8);- const end = performance.now();- const time = end - start;+ test(+ 'Should only keep 10 cache entries (3D)',+ () => {+ const start = performance.now();+ noise3D('seed-1', 0.5, 0.5, 0.8);+ const end = performance.now();+ const time = end - start;- noise3D('seed-2', 0.5, 0.5, 0.8);- noise3D('seed-3', 0.5, 0.5, 0.8);- noise3D('seed-4', 0.5, 0.5, 0.8);- noise3D('seed-5', 0.5, 0.5, 0.8);- noise3D('seed-6', 0.5, 0.5, 0.8);- noise3D('seed-7', 0.5, 0.5, 0.8);- noise3D('seed-8', 0.5, 0.5, 0.8);- noise3D('seed-9', 0.5, 0.5, 0.8);- noise3D('seed-10', 0.5, 0, 0.85);- noise3D('seed-11', 0.5, 0, 0.85);- noise3D('seed-12', 0.5, 0, 0.85);+ noise3D('seed-2', 0.5, 0.5, 0.8);+ noise3D('seed-3', 0.5, 0.5, 0.8);+ noise3D('seed-4', 0.5, 0.5, 0.8);+ noise3D('seed-5', 0.5, 0.5, 0.8);+ noise3D('seed-6', 0.5, 0.5, 0.8);+ noise3D('seed-7', 0.5, 0.5, 0.8);+ noise3D('seed-8', 0.5, 0.5, 0.8);+ noise3D('seed-9', 0.5, 0.5, 0.8);+ noise3D('seed-10', 0.5, 0, 0.85);+ noise3D('seed-11', 0.5, 0, 0.85);+ noise3D('seed-12', 0.5, 0, 0.85);- const start2 = performance.now();- noise3D('seed-1', 0.5, 0.5, 0.8);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 4).toBeGreaterThan(time);- });+ const start2 = performance.now();+ noise3D('seed-1', 0.5, 0.5, 0.8);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 4).toBeGreaterThan(time);+ },+ {retry: 2}+ );- test('Should only keep 10 cache entries (4D)', () => {- const start = performance.now();- noise4D('seed-1', 0.5, 0.5, 0.8, 9);- const end = performance.now();- const time = end - start;+ test(+ 'Should only keep 10 cache entries (4D)',+ () => {+ const start = performance.now();+ noise4D('seed-1', 0.5, 0.5, 0.8, 9);+ const end = performance.now();+ const time = end - start;- noise4D('seed-2', 0.5, 0.5, 0.8, 9);- noise4D('seed-3', 0.5, 0.5, 0.8, 9);- noise4D('seed-4', 0.5, 0.5, 0.8, 9);- noise4D('seed-5', 0.5, 0.5, 0.8, 9);- noise4D('seed-6', 0.5, 0.5, 0.8, 9);- noise4D('seed-7', 0.5, 0.5, 0.8, 9);- noise4D('seed-8', 0.5, 0.5, 0.8, 9);- noise4D('seed-9', 0.5, 0.5, 0.8, 9);- noise4D('seed-10', 0.5, 0, 0.85, 9);- noise4D('seed-11', 0.5, 0, 0.85, 9);- noise4D('seed-12', 0.5, 0, 0.85, 9);+ noise4D('seed-2', 0.5, 0.5, 0.8, 9);+ noise4D('seed-3', 0.5, 0.5, 0.8, 9);+ noise4D('seed-4', 0.5, 0.5, 0.8, 9);+ noise4D('seed-5', 0.5, 0.5, 0.8, 9);+ noise4D('seed-6', 0.5, 0.5, 0.8, 9);+ noise4D('seed-7', 0.5, 0.5, 0.8, 9);+ noise4D('seed-8', 0.5, 0.5, 0.8, 9);+ noise4D('seed-9', 0.5, 0.5, 0.8, 9);+ noise4D('seed-10', 0.5, 0, 0.85, 9);+ noise4D('seed-11', 0.5, 0, 0.85, 9);+ noise4D('seed-12', 0.5, 0, 0.85, 9);- const start2 = performance.now();- noise4D('seed-1', 0.5, 0.5, 0.8, 9);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 4).toBeGreaterThan(time);- });+ const start2 = performance.now();+ noise4D('seed-1', 0.5, 0.5, 0.8, 9);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 4).toBeGreaterThan(time);+ },+ {+ retry: 2,+ }+ );}