This package provides custom Vitest matchers for `aws-sdk-client-mock`, a library used to mock the AWS SDK for JavaScript v3 clients in tests. It enables developers to write expressive assertions about how AWS service commands are called on their mocked clients within a Vitest testing environment. The current stable version is `7.0.1`, with releases often aligned with major Vitest versions. Key differentiators include its tight integration with Vitest's `expect` API, offering a wide range of matchers such as `toHaveReceivedCommand`, `toHaveReceivedCommandWith`, and `toHaveReceivedCommandTimes`. This package fills a crucial gap for Vitest users, providing functionality analogous to `aws-sdk-client-mock-jest` for Jest, allowing for robust verification of AWS SDK interactions in unit and integration tests.
npm install aws-sdk-client-mock-vitestVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure Vitest to automatically load the custom matchers and then write a test verifying an S3 `GetObjectCommand` call using `toHaveReceivedCommandExactlyOnceWith`.
Upgrade your Node.js environment to version 20 or higher. Alternatively, if Node.js 18 is required, stick to `aws-sdk-client-mock-vitest@^6.2.1` and Vitest v3.
Ensure your `aws-sdk-client-mock-vitest` version matches your `vitest` version. Refer to the package README or release notes for specific version mapping guidance.
Always install `aws-sdk-client-mock` and `@smithy/types` alongside `aws-sdk-client-mock-vitest`, ensuring their versions are compatible with each other and the AWS SDK v3 client libraries being mocked.
Ensure you are using `aws-sdk-client-mock-vitest` version `6.1.1` or newer, or update `@vitest/expect` to `^3.0.5` or later directly if managing dependencies manually.
Add `setupFiles: ['./tests/setup.ts']` (or your chosen path) to your `vite.config.ts`'s `test` block, and ensure `tests/setup.ts` contains `import 'aws-sdk-client-mock-vitest/extend';` or `expect.extend(allCustomMatcher);`.
Verify that your `vite.config.ts` includes `setupFiles: ['path/to/your/setup.ts']` under the `test` configuration, and that the specified `setup.ts` file correctly imports `aws-sdk-client-mock-vitest/extend` or calls `expect.extend(allCustomMatcher)`.
Upgrade your Node.js runtime to version 20 or newer. Check the `engines` field in the package.json for compatible Node.js versions and ensure your `vitest` version is also compatible with your Node.js environment.
Ensure you have explicitly installed `aws-sdk-client-mock` and `@smithy/types` in your project, e.g., `npm install aws-sdk-client-mock @smithy/types --save-dev`, and that their versions are compatible with your installed `aws-sdk-client-mock-vitest`.