@postnord/dynamodb-test-suit
v0.0.13
Published
A set of methods to ease unit testing DynamoDB-based project
Downloads
15
Maintainers
Keywords
Readme
A library that abstracts away the complexities of testing dynamodb-based project. It will run an in-memory version of DynamoDB locally and will give you a couple of methods that eliminates the need to mock db calls.
Installation
You need to have Java installed (since DynamoDB is written in it). Run npm i -D @postnord/dynamodb-test-suit
and you're good to go.
Usage
// in your test suit
beforeAll(async () => {
await testDbService.initTestDb()
dbService.getMapper = () => testDbService.getMapper()
})
API
initTestDb()
Will initialize the DB connection and allow you to use the rest of the functions.
await initTestDb()
getTableSnapshot()
Will capture a snapshot of the table.
expect(await getTableSnapshot()).toMatchSnapshot()
flushTable()
Will drop the test DB.
afterAll(async () => {
await flushTable()
})