DEV.co
Open-Source Testing · m-radzikowski

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.

Source: GitHub — github.com/m-radzikowski/aws-sdk-client-mock
905
GitHub stars
49
Forks
TypeScript
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorym-radzikowski/aws-sdk-client-mock
Ownerm-radzikowski
Primary languageTypeScript
LicenseMIT — OSI-approved
Stars905
Forks49
Open issues31
Latest releasev4.1.0 (2024-10-15)
Last updated2026-01-29
Sourcehttps://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.

Quickstart

Get the aws-sdk-client-mock source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/m-radzikowski/aws-sdk-client-mock.gitcd aws-sdk-client-mock# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Lambda function testing

Mock AWS service calls (SNS, DynamoDB, S3) within Lambda handlers to isolate business logic and avoid integration test overhead.

Microservice unit tests

Test application code that consumes AWS services without requiring live credentials or integration test infrastructure.

Payment/financial transaction workflows

Mock SQS, SNS, and DynamoDB interactions to test event-driven architectures and message processing pipelines in isolation.

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.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

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.

Software development agency

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.co

Related 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?
No. aws-sdk-client-mock is designed exclusively for AWS SDK v3 (@aws-sdk/* modular clients). SDK v2 users need alternative mocking libraries or must upgrade.
Can I mock custom AWS SDK configuration or credentials?
The mock intercepts command execution, bypassing configuration. Test configuration code separately via integration tests or use getClient() callback in callsFake() to inspect client state.
What happens if I don't specify a mock behavior?
By default, mocked Client#send() returns undefined. Use .onAnyCommand().resolves({}) or .resolves({}) to define a catch-all default.
Does this library require AWS credentials?
No. Mocking intercepts all command execution before credential validation, so no credentials, network access, or AWS account access is needed.

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.