Skip to content

Commit bdfbb7c

Browse files
committed
test(storage): mock aws-sdk in s3 unit tests
The AWS SDK is a bring-your-own dependency and is not installed in CI. Stub @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner via vi.mock so loading s3.ts (which statically imports both) does not require the real packages. Verified by removing @aws-sdk from node_modules and rerunning: all 26 resolveS3Config tests pass.
1 parent f5fa1ed commit bdfbb7c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/core/tests/unit/storage/s3.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@
66

77
import { describe, it, expect, vi, afterEach } from "vitest";
88

9+
// The AWS SDK is a "bring-your-own" dependency of emdash core — it is NOT
10+
// installed in CI. Stub it here so loading s3.ts (which statically imports
11+
// both modules) does not require the real package.
12+
vi.mock("@aws-sdk/client-s3", () => {
13+
class S3Client {
14+
send(_command: unknown): Promise<unknown> {
15+
return Promise.resolve({});
16+
}
17+
}
18+
class Command {
19+
constructor(public input: unknown) {}
20+
}
21+
return {
22+
S3Client,
23+
PutObjectCommand: Command,
24+
GetObjectCommand: Command,
25+
DeleteObjectCommand: Command,
26+
HeadObjectCommand: Command,
27+
ListObjectsV2Command: Command,
28+
};
29+
});
30+
31+
vi.mock("@aws-sdk/s3-request-presigner", () => ({
32+
getSignedUrl: () => Promise.resolve("https://signed.example.com/fake"),
33+
}));
34+
935
import { resolveS3Config, createStorage } from "../../../src/storage/s3.js";
1036
import { EmDashStorageError } from "../../../src/storage/types.js";
1137

0 commit comments

Comments
 (0)