https://github.com/cdaringe/ava-fixture-docker-db
acquire a fresh docker database container attached to your ava test context
https://github.com/cdaringe/ava-fixture-docker-db
ava database docker node postgres typescript
Last synced: 8 days ago
JSON representation
acquire a fresh docker database container attached to your ava test context
- Host: GitHub
- URL: https://github.com/cdaringe/ava-fixture-docker-db
- Owner: cdaringe
- Created: 2018-12-16T00:59:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-03T10:36:47.000Z (9 months ago)
- Last Synced: 2025-04-22T16:02:45.662Z (14 days ago)
- Topics: ava, database, docker, node, postgres, typescript
- Language: TypeScript
- Homepage:
- Size: 516 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-ava - ava-fixture-docker-db - Add docker databases to your test contexts. (Packages)
README
# ava-fixture-docker-db
acquire a fresh docker database container attached to your ava test context
[](https://standardjs.com) [](https://github.com/semantic-release/semantic-release) [](https://greenkeeper.io/) [](https://circleci.com/gh/cdaringe/ava-fixture-docker-db)
## usage
```ts
import ava, { TestInterface } from 'ava'
import { db, DbContext } from 'ava-fixture-docker-db'const test = ava as TestInterface
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.