Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit a8fef99

Browse files
fix issue around aws sdk manual mocks
1 parent 8e57a2e commit a8fef99

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/s3-static-assets/__mocks__/aws-sdk.ts renamed to packages/s3-static-assets/tests/aws-sdk.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare module "aws-sdk" {
22
const mockUpload: jest.Mock;
33
const mockGetBucketAccelerateConfiguration: jest.Mock;
4+
const mockGetBucketAccelerateConfigurationPromise: jest.Mock;
45
}
56

67
const promisifyMock = (mockFn: jest.Mock): jest.Mock => {

packages/s3-static-assets/tests/upload-assets.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import path from "path";
22
import uploadStaticAssets from "../src/index";
33
import { IMMUTABLE_CACHE_CONTROL_HEADER } from "../src/lib/constants";
4-
import AWS, { mockGetBucketAccelerateConfiguration, mockUpload } from "aws-sdk";
5-
import { mockGetBucketAccelerateConfigurationPromise } from "../__mocks__/aws-sdk";
4+
import AWS, {
5+
mockGetBucketAccelerateConfigurationPromise,
6+
mockGetBucketAccelerateConfiguration,
7+
mockUpload
8+
} from "aws-sdk";
9+
10+
// unfortunately can't use __mocks__ because aws-sdk is being mocked in other
11+
// packages in the monorepo
12+
// https://github.com/facebook/jest/issues/2070
13+
jest.mock("aws-sdk", () => require("./aws-sdk.mock"));
614

715
const upload = (): Promise<AWS.S3.ManagedUpload.SendData[]> => {
816
return uploadStaticAssets({

0 commit comments

Comments
 (0)