Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-28T22:08:35.000Z (7 months ago)
- Last Synced: 2024-05-29T13:04:36.812Z (7 months ago)
- Topics: ava, database, docker, node, postgres, typescript
- Language: TypeScript
- Homepage:
- Size: 817 KB
- Stars: 4
- Watchers: 3
- 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
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Greenkeeper badge](https://badges.greenkeeper.io/cdaringe/postgraphile-upsert.svg)](https://greenkeeper.io/) [![CircleCI](https://circleci.com/gh/cdaringe/ava-fixture-docker-db.svg?style=svg)](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.