# @pubcore/knex-create-test-db

> helper for unittest to create database table with knex

Latest version **1.1.13** (published 2022-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pubcore/knex-create-test-db
pnpm add @pubcore/knex-create-test-db
yarn add @pubcore/knex-create-test-db
bun add @pubcore/knex-create-test-db
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.13 |
| Published | 2022-03-31 |
| First published | 2018-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | pubcore |
| Maintainers | dominix, jacklrs, fidorw |
| Keywords | knex, unittest |

## Links

- npm: https://www.npmjs.com/package/@pubcore/knex-create-test-db
- Repository: https://github.com/pubcore/knex-create-test-db
- Homepage: https://github.com/pubcore/knex-create-test-db#readme
- Issues: https://github.com/pubcore/knex-create-test-db/issues
- npm.io page: https://npm.io/package/@pubcore/knex-create-test-db

## Dependencies (5)

- [knex](https://npm.io/package/knex.md) ^1.0.4
- [moment](https://npm.io/package/moment.md) ^2.27.0
- [sqlite](https://npm.io/package/sqlite.md) ^4.0.19
- [sqlite3](https://npm.io/package/sqlite3.md) ^4.2.0
- [@vscode/sqlite3](https://npm.io/package/@vscode/sqlite3.md) ^5.0.8

## Recent versions

- 1.1.13 (latest) — 2022-03-31
- 1.1.12 — 2021-01-16
- 1.1.11 — 2020-08-06
- 1.1.10 — 2020-05-10
- 1.1.9 — 2020-05-08
- 1.1.8 — 2020-05-08
- 1.1.7 — 2020-05-08
- 1.1.6 — 2020-03-20
- 1.1.5 — 2019-10-24
- 1.1.4 — 2019-08-29
- 1.1.3 — 2019-07-19
- 1.1.2 — 2019-07-16
- 1.1.1 — 2019-06-02
- 1.1.0 — 2019-04-11
- 1.0.0 — 2018-08-20

## README

## Helper to create on-the-fly sql database tables to test knex with mocha

#### Prerequisite
* mocha used for tests
* knex used for database (RDMS) persitence functions to test

#### Example
```
import {expect} from 'chai'
import createKnex from '@pubcore/knex-create-test-db'

var rows = [
    {author:'king', published:new Date(), sold:42}
  ],
  table = 'books',
  dbTypes = {author:'string', published:'dateTime', sold:'integer'}

describe('create test db', () => {
  //The test table will be created and droped for each "it" ("beforeEach" callback)
  //Knex will be destroyed after "describe" block finished ("after" callback)

  var knex = createKnex({table, rows, beforeEach, after, dbTypes})

  it('can be used to test some functionality dealing with a knex api', () => {
    expect( bookAvailable({author:'king'}, {db:{knex}}) ).to.be.true
  })
})
```

---
_Source: https://npm.io/package/@pubcore/knex-create-test-db · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
