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

Commit df3e09e

Browse files
move console warn spy to be / ae
1 parent b35d6e6 commit df3e09e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ const upload = (): Promise<AWS.S3.ManagedUpload.SendData[]> => {
1717
};
1818

1919
describe("Upload tests", () => {
20+
let consoleWarnSpy: jest.SpyInstance;
21+
22+
beforeEach(() => {
23+
consoleWarnSpy = jest.spyOn(console, "warn").mockReturnValue();
24+
});
25+
26+
afterEach(() => {
27+
consoleWarnSpy.mockRestore();
28+
});
29+
2030
it("passes credentials to S3 client", async () => {
2131
await upload();
2232

@@ -47,18 +57,16 @@ describe("Upload tests", () => {
4757
});
4858

4959
it("falls back to non accelerated client if checking for bucket acceleration throws an error", async () => {
50-
const warnSpy = jest.spyOn(console, "warn").mockReturnValueOnce();
51-
5260
mockGetBucketAccelerateConfigurationPromise.mockRejectedValueOnce(
5361
new Error("Unexpected error!")
5462
);
5563

5664
await upload();
5765

58-
expect(warnSpy).toBeCalledWith(expect.stringContaining("falling back"));
66+
expect(consoleWarnSpy).toBeCalledWith(
67+
expect.stringContaining("falling back")
68+
);
5969
expect(AWS.S3).toBeCalledTimes(1);
60-
61-
warnSpy.mockRestore();
6270
});
6371

6472
it("uploads any contents inside build directory specified in BUILD_ID", async () => {

0 commit comments

Comments
 (0)