1.1.13 • Published 2 years ago

@pubcore/knex-create-test-db v1.1.13

Weekly downloads
19
License
MIT
Repository
github
Last release
2 years ago

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
  })
})
1.1.13

2 years ago

1.1.12

3 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago