🎥 Make videos programmatically with React
fix lambda tests
Jonny Burger3f13c69737d5
diff --git a/packages/lambda/src/shared/__mocks__/aws-clients.ts b/packages/lambda/src/shared/__mocks__/aws-clients.tsdeleted file mode 100644index 097d3fb711..0000000000--- a/packages/lambda/src/shared/__mocks__/aws-clients.ts+++ /dev/null@@ -1,31 +0,0 @@-import type {- InvokeWithResponseStreamCommandInput,- LambdaClient,-} from '@aws-sdk/client-lambda';-import type {getLambdaClient as original} from '../../shared/aws-clients';--export const getLambdaClient: typeof original = (region, timeoutInTest) => {- return {- config: {- requestHandler: {},- apiVersion: 'fake',- },- destroy: () => undefined,- middlewareStack: undefined,- send: async (params: {- FunctionName: undefined;- Payload: InvokeWithResponseStreamCommandInput;- InvocationType: 'Event';- }) => {- // @ts-expect-error- const payload = JSON.parse(params.input.Payload);-- const {handler} = await import('../../functions/index');-- return handler(payload, {- invokedFunctionArn: 'arn:fake',- getRemainingTimeInMillis: () => timeoutInTest ?? 120000,- });- },- } as unknown as LambdaClient;-};diff --git a/packages/lambda/src/shared/aws-clients.ts b/packages/lambda/src/shared/aws-clients.tsindex c4c2f14d4c..ac306dc1d6 100644--- a/packages/lambda/src/shared/aws-clients.ts+++ b/packages/lambda/src/shared/aws-clients.ts@@ -1,5 +1,6 @@import {CloudWatchLogsClient} from '@aws-sdk/client-cloudwatch-logs';import {IAMClient} from '@aws-sdk/client-iam';+import type {InvokeWithResponseStreamCommandInput} from '@aws-sdk/client-lambda';import {LambdaClient} from '@aws-sdk/client-lambda';import {S3Client} from '@aws-sdk/client-s3';import {ServiceQuotasClient} from '@aws-sdk/client-service-quotas';@@ -246,6 +247,32 @@ export const getLambdaClient = (// eslint-disable-next-line @typescript-eslint/no-unused-vars_timeoutInTest?: number,): LambdaClient => {+ if (process.env.VITEST) {+ return {+ config: {+ requestHandler: {},+ apiVersion: 'fake',+ },+ destroy: () => undefined,+ middlewareStack: undefined,+ send: async (params: {+ FunctionName: undefined;+ Payload: InvokeWithResponseStreamCommandInput;+ InvocationType: 'Event';+ }) => {+ // @ts-expect-error+ const payload = JSON.parse(params.input.Payload);++ const {handler} = await import('../functions/index');++ return handler(payload, {+ invokedFunctionArn: 'arn:fake',+ getRemainingTimeInMillis: () => _timeoutInTest ?? 120000,+ });+ },+ } as unknown as LambdaClient;+ }+return getServiceClient({region,service: 'lambda',diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.tsindex ec951003c9..7f33327d33 100644--- a/packages/lambda/src/test/integration/webhooks.test.ts+++ b/packages/lambda/src/test/integration/webhooks.test.ts@@ -1,15 +1,6 @@import {RenderInternals} from '@remotion/renderer';import {VERSION} from 'remotion/version';-import {- afterAll,- afterEach,- beforeAll,- beforeEach,- describe,- expect,- test,- vi,-} from 'vitest';+import {beforeAll, beforeEach, describe, expect, test, vi} from 'vitest';import {LambdaRoutines} from '../../defaults';import {callLambda} from '../../shared/call-lambda';import {mockableHttpClients} from '../../shared/invoke-webhook';@@ -33,20 +24,18 @@ beforeEach(() => {};},);-});--afterEach(() => {- mockableHttpClients.http = originalFetch;+ return () => {+ mockableHttpClients.http = originalFetch;+ };});beforeAll(() => {disableLogs();-});--afterAll(async () => {- enableLogs();+ return async () => {+ enableLogs();- await RenderInternals.killAllBrowsers();+ await RenderInternals.killAllBrowsers();+ };});const TEST_URL = 'http://localhost:8000';@@ -54,6 +43,7 @@ const TEST_URL = 'http://localhost:8000';describe('Webhooks', () => {test('Should call webhook upon completion', async () => {process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '2048';+ process.env.AWS_LAMBDA_FUNCTION_NAME = 'remotion-dev-lambda';const res = await callLambda({type: LambdaRoutines.start,diff --git a/packages/lambda/src/test/setup.ts b/packages/lambda/src/test/setup.tsindex 9247456a41..519f7b41ef 100644--- a/packages/lambda/src/test/setup.ts+++ b/packages/lambda/src/test/setup.ts@@ -41,9 +41,6 @@ vi.mock('../shared/bundle-site', () =>vi.mock('../shared/get-account-id', () =>vi.importActual('../shared/__mocks__/get-account-id'),);-vi.mock('../shared/aws-clients', () =>- vi.importActual('../shared/__mocks__/aws-clients'),-);vi.mock('../api/create-bucket', () =>vi.importActual('../api/__mocks__/create-bucket'),);