🎥 Make videos programmatically with React
Remove Prettier imports and spies from codemod tests
JonnyBurger405e6359a6d8
diff --git a/packages/browser-studio/src/test/browser-studio-operations.test.ts b/packages/browser-studio/src/test/browser-studio-operations.test.tsindex ab63f7f651..bdf01c69fa 100644--- a/packages/browser-studio/src/test/browser-studio-operations.test.ts+++ b/packages/browser-studio/src/test/browser-studio-operations.test.ts@@ -1,7 +1,6 @@-import {expect, spyOn, test} from 'bun:test';+import {expect, test} from 'bun:test';import {createElementPayload} from '@remotion/studio-protocol';import type {EventSourceEvent} from '@remotion/studio-shared';-import * as prettier from 'prettier/standalone';import type {InteractivitySchema} from 'remotion';import {NoReactInternals} from 'remotion/no-react';import {@@ -1250,46 +1249,39 @@ test('creates a composition with a component file in the root file', async () =>newDurationInFrames: 90,canvasCapture: null,};- const formatter = spyOn(prettier, 'format').mockImplementation(() => {- throw new Error('Prettier must not be called');+ const result = await operations.applyCodemod({+ codemod,+ dryRun: false,+ symbolicatedStack: null,});- try {- const result = await operations.applyCodemod({- codemod,- dryRun: false,- symbolicatedStack: null,- });- if (!result.success) {- throw new Error(result.reason);- }+ if (!result.success) {+ throw new Error(result.reason);+ }- const rootFile = getProject().files['/project/src/Root.tsx'];- expect(rootFile).toContain('id="FreshComp"');- expect(rootFile).toContain('import { Composition } from "remotion"');- expect(rootFile).toContain('import { FreshComp } from "./FreshComp"');- expect(getProject().files['/project/src/FreshComp.tsx']).toContain(- 'export const FreshComp: React.FC',- );+ const rootFile = getProject().files['/project/src/Root.tsx'];+ expect(rootFile).toContain('id="FreshComp"');+ expect(rootFile).toContain('import { Composition } from "remotion"');+ expect(rootFile).toContain('import { FreshComp } from "./FreshComp"');+ expect(getProject().files['/project/src/FreshComp.tsx']).toContain(+ 'export const FreshComp: React.FC',+ );- const conflict = await operations.applyCodemod({- codemod: {...codemod, newId: 'FreshComp2'},- dryRun: false,- symbolicatedStack: null,- });- expect(conflict).toEqual({- success: false,- reason: 'Cannot create src/FreshComp.tsx because it already exists',- });+ const conflict = await operations.applyCodemod({+ codemod: {...codemod, newId: 'FreshComp2'},+ dryRun: false,+ symbolicatedStack: null,+ });+ expect(conflict).toEqual({+ success: false,+ reason: 'Cannot create src/FreshComp.tsx because it already exists',+ });- const undoResult = await operations.undo();- expect(undoResult.success).toBe(true);- expect(getProject().files['/project/src/FreshComp.tsx']).toBeUndefined();- expect(getProject().files['/project/src/Root.tsx']).not.toContain(- 'id="FreshComp"',- );- } finally {- formatter.mockRestore();- }+ const undoResult = await operations.undo();+ expect(undoResult.success).toBe(true);+ expect(getProject().files['/project/src/FreshComp.tsx']).toBeUndefined();+ expect(getProject().files['/project/src/Root.tsx']).not.toContain(+ 'id="FreshComp"',+ );});test('creates, renames and deletes a folder in Browser Studio', async () => {diff --git a/packages/studio-server/src/test/apply-codemod.test.ts b/packages/studio-server/src/test/apply-codemod.test.tsindex ea000a7cad..6284c977c2 100644--- a/packages/studio-server/src/test/apply-codemod.test.ts+++ b/packages/studio-server/src/test/apply-codemod.test.ts@@ -9,7 +9,6 @@ import {import {tmpdir} from 'node:os';import path from 'node:path';import type {RecastCodemod} from '@remotion/studio-shared';-import * as prettier from 'prettier';import {parseAndApplyCodemod} from '../codemods/duplicate-composition';import {createFileWatcherRegistry,@@ -402,16 +401,6 @@ const runCompositionCodemodUndoRedoTest = async ({? spyOn(console, 'log').mockImplementation(() => undefined): null;- const formatter = [- 'duplicate-composition',- 'rename-composition',- 'delete-composition',- ].includes(codemod.type)- ? spyOn(prettier, 'format').mockImplementation(() => {- throw new Error('Prettier must not be called');- })- : null;-try {clearUndoRedoStacks();const entryPoint = path.join(remotionRoot, 'Root.tsx');@@ -464,7 +453,6 @@ const runCompositionCodemodUndoRedoTest = async ({expect(getUndoStack().length).toBe(1);expect(getRedoStack().length).toBe(0);} finally {- formatter?.mockRestore();clearUndoRedoStacks();cleanupLiveEvents();cleanupFileWatcher();@@ -677,10 +665,6 @@ test('applyCodemodHandler creates new composition files with undo and redo', asyaddNewClientListener: () => () => undefined,});- const formatter = spyOn(prettier, 'format').mockImplementation(() => {- throw new Error('Prettier must not be called');- });-try {clearUndoRedoStacks();const entryPoint = path.join(remotionRoot, 'Root.tsx');@@ -758,7 +742,6 @@ test('applyCodemodHandler creates new composition files with undo and redo', asy'export const FreshVideo',);} finally {- formatter.mockRestore();clearUndoRedoStacks();cleanupLiveEvents();cleanupFileWatcher();@@ -779,10 +762,6 @@ test('applyCodemodHandler creates an interactive Canvas Capture composition', asaddNewClientListener: () => () => undefined,});- const formatter = spyOn(prettier, 'format').mockImplementation(() => {- throw new Error('Prettier must not be called');- });-try {clearUndoRedoStacks();const entryPoint = path.join(remotionRoot, 'Root.tsx');@@ -873,7 +852,6 @@ test('applyCodemodHandler creates an interactive Canvas Capture composition', asexpect(readFileSync(entryPoint, 'utf-8')).toBe(rootContents);expect(existsSync(componentFile)).toBe(false);} finally {- formatter.mockRestore();clearUndoRedoStacks();cleanupLiveEvents();cleanupFileWatcher();