# ava-fixture-docker-db

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

Latest version **1.0.14** (published 2023-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ava-fixture-docker-db
pnpm add ava-fixture-docker-db
yarn add ava-fixture-docker-db
bun add ava-fixture-docker-db
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2023-12-28 |
| First published | 2018-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 21 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | cdaringe |
| Maintainers | cdaringe, wa11-e |
| Keywords | ava, docker, test, context, database, postgres, node, typescript |

## Links

- npm: https://www.npmjs.com/package/ava-fixture-docker-db
- Repository: https://github.com/cdaringe/ava-fixture-docker-db
- Homepage: https://github.com/cdaringe/ava-fixture-docker-db#readme
- Issues: https://github.com/cdaringe/ava-fixture-docker-db/issues
- npm.io page: https://npm.io/package/ava-fixture-docker-db

## Dependencies (8)

- [execa](https://npm.io/package/execa.md) ^1.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [freeport](https://npm.io/package/freeport.md) ^1
- [dockerode](https://npm.io/package/dockerode.md) ^4.0.0
- [@types/execa](https://npm.io/package/@types/execa.md) ^0
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.138
- [@types/freeport](https://npm.io/package/@types/freeport.md) ^1
- [@types/dockerode](https://npm.io/package/@types/dockerode.md) ^3.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.14 (latest) — 2023-12-28
- 1.0.13 — 2023-12-23
- 1.0.12 — 2023-11-07
- 1.0.11 — 2023-10-18
- 1.0.10 — 2023-10-12
- 1.0.9 — 2023-04-07
- 1.0.8 — 2021-04-19
- 1.0.7 — 2021-04-19
- 1.0.6 — 2020-10-21
- 1.0.5 — 2020-08-25
- 1.0.4 — 2019-09-24
- 1.0.3 — 2019-09-23
- 1.0.2 — 2018-12-16
- 1.0.1 — 2018-12-16
- 1.0.0 — 2018-12-16

## 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<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.

---
_Source: https://npm.io/package/ava-fixture-docker-db · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
