jest-dynalite
![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)
Enchanced @shelf/jest-dynamodb
jest-dynalite
is a fork of @shelf/jest-dynamodb
used to allow unit tests
to perform dynamodb queries locally.
Behaviour
jest-dynalite
runs a dynalite instance per test runner, which means
test runners do not interfear with eachother.
jest-dynalite
clears tables between tests, so every test has a clean environment to run in.
Usage
yarn add jest-dynalite -D
jest.config.js
module.exports = {
...
preset: "./jest-preset.js"
}
Create a jest-dynalite-config.json
in your package root, which contain the tables
which should exist for your tests.
{
"tables": [
{
...
}
],
"basePort": 8000
}
Usage
const ddb = new DocumentClient({
...yourConfig,
...(process.env.MOCK_DYNAMODB_ENDPOINT && {
endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
sslEnabled: false,
region: "local"
})
});
process.env.MOCK_DYNAMODB_ENDPOINT
is unqiue to test runner
License
MIT