sls-jest
v1.0.0-alpha.9
Published
A collection of matchers and spies for testing AWS serverless applications
Downloads
70
Readme
sls-jest
A jest extension to test serverless applications.
Testing serverless applications is hard. Ideally, you want to test against the real infrastrucutre and avoid mocks. e.g. a real DynamoDB table, real Lambda functions. However, the asynchronous nature of serverless makes it difficult to write tests that work and are deterministic.
This library offers a suite of tools that help solve, or at least mitigate, those issues. It is built on top of the famous jest library and adds new serverless-related matchers.
Getting started
Install sls-jest
npm i sls-jest
Setup Jest
Create a setup file:
// setupJest.ts
import { matchers } from 'sls-jest';
expect.extend(matchers);
Then use it in your jest config file (jest.config.ts
) under setupFilesAfterEnv
:
export default {
// ..
setupFilesAfterEnv: ['./setupJest.ts'];
}
Documentation
For full documentation and guides, read the documentation website.