0.0.13 • Published 4 years ago

@postnord/dynamodb-test-suit v0.0.13

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
4 years ago

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()
})