aws-sdk-client-mock
aws-sdk-client-mock is a TypeScript library for mocking AWS SDK v3 clients in unit tests. It provides a fluent, type-safe API to define mock behavior for specific commands and payloads, with support for spying on calls and Jest matchers.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | m-radzikowski/aws-sdk-client-mock |
| Owner | m-radzikowski |
| Primary language | TypeScript |
| License | MIT — OSI-approved |
| Stars | 905 |
| Forks | 49 |
| Open issues | 31 |
| Latest release | v4.1.0 (2024-10-15) |
| Last updated | 2026-01-29 |
| Source | https://github.com/m-radzikowski/aws-sdk-client-mock |
What aws-sdk-client-mock is
A modular mocking library for @aws-sdk/* clients using a command-based matching system. Supports fluent chaining, payload-based behavior matching, consecutive call sequences (resolvesOnce/rejectsOnce), custom callbacks, and integration with Jest/Vitest assertion libraries.
Get the aws-sdk-client-mock source
Clone the repository and explore it locally.
git clone https://github.com/m-radzikowski/aws-sdk-client-mock.gitcd aws-sdk-client-mock# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Requires AWS SDK v3.363.0 or later; verify version compatibility with project dependencies to avoid @smithy/types conflicts.
- Mock setup/teardown must be explicit (mockClient, restore, reset); use Jest/Vitest lifecycle hooks (beforeEach/afterEach) to prevent test pollution.
- Payload matching is partial by default; enable strict: true for exact payload matching to catch unintended parameter variations.
- Chained behaviors (resolvesOnce/rejectsOnce) execute in definition order; verify test expectations align with call sequence.
- Type safety is enforced at compile time; IDE/TypeScript catch many mistakes, but runtime behavior requires test execution.
When to avoid it — and what to weigh
- SDK v2 dependency — This library targets AWS SDK v3 only. Legacy applications using SDK v2 (@aws-sdk/js) will require a different mocking approach or SDK upgrade.
- Integration/end-to-end testing required — Mocks hide real AWS service behavior, regional limits, and eventual consistency issues. Integration tests against a test AWS environment remain necessary.
- Non-AWS SDK AWS interactions — This library only mocks official AWS SDK clients. Custom HTTP clients or third-party AWS wrappers will need alternative mocking strategies.
- Browser-only environments without Node.js — Primarily designed for Node.js and Electron; browser-only environments may have limited or untested support.
License & commercial use
MIT License. Permissive open-source license allowing commercial use, modification, and distribution with attribution.
MIT License explicitly permits commercial use without restriction. No known limitations on proprietary application usage. No commercial support tier documented in the repository; reliance on community/GitHub issues.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
No real AWS credentials or network calls occur during mocking, reducing test environment security risk. Mocks may mask real AWS error conditions (throttling, permission denial) that production code should handle; integration tests remain necessary for security-sensitive workflows.
Alternatives to consider
jest-mock-aws-sdk
Older Jest-only mocking approach; lacks fluent API, type safety, and active maintenance compared to aws-sdk-client-mock.
AWS SDK v3 LocalStack/MinIO
Local service emulation for integration tests; higher setup complexity but captures real service behavior and is unsuitable for fast unit tests.
Manual jest.mock() or test doubles
Requires custom boilerplate; loses type safety and lacks payload-based matching, matchers, and spy convenience.
Build on aws-sdk-client-mock with DEV.co software developers
Install aws-sdk-client-mock via npm and review the GitHub README for fluent API examples, or contact us to discuss integration into your test strategy.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
aws-sdk-client-mock FAQ
Does this mock work with AWS SDK v2?
Can I mock custom AWS SDK configuration or credentials?
What happens if I don't specify a mock behavior?
Does this library require AWS credentials?
Software developers & web developers for hire
Need help beyond evaluating aws-sdk-client-mock? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source testing integrations — and maintain them long-term.
Ready to mock AWS services in your tests?
Install aws-sdk-client-mock via npm and review the GitHub README for fluent API examples, or contact us to discuss integration into your test strategy.