https://github.com/serverless-guru/sls-jest
A collection of matchers and spies for testing AWS serverless applications
https://github.com/serverless-guru/sls-jest
Last synced: 5 months ago
JSON representation
A collection of matchers and spies for testing AWS serverless applications
- Host: GitHub
- URL: https://github.com/serverless-guru/sls-jest
- Owner: serverless-guru
- Created: 2022-08-01T19:22:17.000Z (almost 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-02-08T13:50:40.000Z (over 2 years ago)
- Last Synced: 2025-10-14T08:49:47.945Z (8 months ago)
- Language: TypeScript
- Homepage: https://serverlessguru.gitbook.io/sls-jest
- Size: 1.44 MB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## sls-jest
[](https://github.com/serverless-guru/sls-jest/actions/workflows/ci.yml) [](https://github.com/serverless-guru/sls-jest/actions/workflows/release.yml)
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](https://jestjs.io/docs/getting-started) library and adds new serverless-related matchers.
# Getting started
## Install sls-jest
```bash
npm i sls-jest
```
## Setup Jest
Create a setup file:
```typescript
// setupJest.ts
import { matchers } from 'sls-jest';
expect.extend(matchers);
```
Then use it in your [jest config file](https://jestjs.io/docs/configuration) (`jest.config.ts`) under `setupFilesAfterEnv`:
```typescript
export default {
// ..
setupFilesAfterEnv: ['./setupJest.ts'];
}
```
## Documentation
For full documentation and guides, read the [documentation website](https://serverlessguru.gitbook.io/sls-jest/).