ava-fixture-docker-db
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

ava-fixture-docker-db

acquire a fresh docker database container attached to your ava test context

JavaScript Style Guide semantic-release Greenkeeper badge CircleCI

usage

import ava, { TestInterface } from 'ava'
import { db, DbContext } from 'ava-fixture-docker-db'

const test = ava as TestInterface<DbContext>

test.beforeEach(t => db.setup(t.context)) // setup(context, dbOptions, dockerodeOptions)
test.afterEach(t => db.teardown(t.context))

test('some that needs a db!', async t => {
  t.is(t.context.dbConfig.username, 'postgres', 'has default postgres user')
  const containerData = await t.context.dbContainer.inspect()
  t.truthy(containerData.Image, 'has docker image')
  t.is(containerData.State.Status, 'running', 'db is running')
  t.is(Object.keys(containerData.HostConfig.PortBindings).length, 1, 'has host port exposed')
})

see the exported typescript typings or source for the simple additional APIs you can use in setup.

Package Sidebar

Install

npm i ava-fixture-docker-db

Weekly Downloads

1

Version

1.0.14

License

MIT

Unpacked Size

21.5 kB

Total Files

17

Last publish

Collaborators

  • cdaringe
  • wa11-e