🎥 Make videos programmatically with React
fix tests
Jonny Burger6695996dc513
diff --git a/.github/workflows/push.yml b/.github/workflows/push.ymlindex 6746808a18..92ef2eff29 100644--- a/.github/workflows/push.yml+++ b/.github/workflows/push.yml@@ -34,7 +34,7 @@ jobs:- name: Testrun: |pnpm build- npx jest --root-dir tests/lambda+ pnpm run testlambdabuild:name: Build Node ${{ matrix.node_version }} - ffmpeg ${{ matrix.ffmpeg_version }} on ${{ matrix.os }}runs-on: ${{ matrix.os }}diff --git a/jest.config.js b/jest.config.jsindex de8d4b4e76..590b5c9601 100644--- a/jest.config.js+++ b/jest.config.js@@ -3,5 +3,4 @@ module.exports = {testEnvironment: "node",rootDir: "tests",testTimeout: 240000,- resetMocks: true,};diff --git a/package.json b/package.jsonindex 0fcc0c6459..7537b5b157 100644--- a/package.json+++ b/package.json@@ -4,7 +4,7 @@"license": "SEE LICENSE IN LICENSE.md","scripts": {"test": "cd packages/core && npm test && cd ../babel-loader && npm test && cd ../bundler && npm test && cd ../cli && npm test && cd ../eslint-plugin && npm test && cd ../gif && npm test && cd ../lambda && npm test && cd ../media-utils && npm test && cd ../player && npm test && cd ../renderer && npm test && cd ../three && npm test && cd ../.. && npx jest --runInBand --root-dir=tests/integration",- "testlambda": "npx jest --root-dir=tests/lambda --setup-files=../../packages/lambda/src/test/setup.ts",+ "testlambda": "npx jest --runInBand --root-dir=tests/lambda --setup-files=../../packages/lambda/src/test/setup.ts","build": "pnpm run build --recursive && lerna bootstrap","watch": "pnpm run watch --recursive --stream --parallel","postinstall": "lerna bootstrap",diff --git a/tests/lambda/cli.test.ts b/tests/lambda/cli.test.tsindex 10adb66613..0fe34a757e 100644--- a/tests/lambda/cli.test.ts+++ b/tests/lambda/cli.test.ts@@ -1,37 +1,62 @@import { cleanFnStore } from "../../packages/lambda/src/api/mock-functions";import { LambdaInternals } from "../../packages/lambda/src/index";-const getConsoleOutput = () => {- // @ts-expect-error- return process.stdout.write.mock.calls.map((c) => c[0].toString()).join("\n");+let stdoutOutput: string[] = [];+let stderrOutput: string[] = [];++const getProcessWriteOutput = () => {+ return stdoutOutput.map((c) => c.toString()).join("\n");};+const originalStdout = process.stdout.write;+const originalStderr = process.stderr.write;++beforeEach(() => {+ stdoutOutput = [];+ stderrOutput = [];+ cleanFnStore();+ // @ts-expect-error+ process.stdout.write = (str: string) => {+ // originalStdout(str);+ stdoutOutput.push(str);+ };++ // @ts-expect-error+ process.stderr.write = (str: string) => {+ // originalStderr(str);+ stderrOutput.push(str);+ };+});++afterEach(() => {+ process.stdout.write = originalStdout;+ process.stderr.write = originalStderr;+});+test("Deploy function", async () => {- process.stdout.write = jest.fn();await LambdaInternals.executeCommand(["functions", "deploy"]);- expect(getConsoleOutput()).toContain("Deployed as remotion-render-abcdef\n");+ expect(getProcessWriteOutput()).toContain(+ "Deployed as remotion-render-abcdef\n"+ );});test("Deploy function and list it", async () => {- cleanFnStore();await LambdaInternals.executeCommand(["functions", "deploy"]);- process.stdout.write = jest.fn();await LambdaInternals.executeCommand(["functions", "ls"]);- expect(getConsoleOutput()).toContain("Getting functions...");- expect(getConsoleOutput()).toContain("Memory (MB)");- expect(getConsoleOutput()).toMatch(+ expect(getProcessWriteOutput()).toContain("Getting functions...");+ expect(getProcessWriteOutput()).toContain("Memory (MB)");+ expect(getProcessWriteOutput()).toMatch(/remotion-render-abcdef\s+(.*)\s+1024\s+120/g);});test("Deploy function and it already exists should fail", async () => {- cleanFnStore();await LambdaInternals.executeCommand(["functions", "deploy"]);await expect(() =>LambdaInternals.executeCommand(["functions", "deploy"])).rejects.toThrow(/Exited process with code 1/);- expect(getConsoleOutput()).toMatch(+ expect(getProcessWriteOutput()).toMatch(/A function with version (.*) is already deployed in region us-east-1, it is called remotion-render-abcdef/);});