1.0.0-alpha.9 • Published 3 months ago

sls-jest v1.0.0-alpha.9

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

sls-jest

Continuous Integration Release


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.