jest-environment-knex
TypeScript icon, indicating that this package has built-in type declarations

3.0.7 • Public • Published

jest-environment-knex

Github Master CI Status codecov NPM version

knex environment in Jest

Tested against SQlite3 and Postgres. See __tests__

Install

$ npm install --save-dev jest-environment-knex
# or
$ yarn -D jest-environment-knex

Usage

const { knex } = global;

beforeAll(async () => {
  await knex.migrate.latest();
  await knex.seed.run();
});

test("should list all tables", async () => {
  const query = `
    SELECT table_name FROM information_schema.tables
    WHERE table_schema = current_schema() AND table_catalog = ?
  `;
  const results = await knex.raw(query, [knex.client.database()]);
  expect(results.rows.map((row) => row.table_name).sort()).toMatchSnapshot();
});

Release policy

Releases are automaticly made through our GitHub Actions strictly following the Semantic Versioning specification thanks to semantic-release.

Readme

Keywords

none

Package Sidebar

Install

npm i jest-environment-knex

Weekly Downloads

2

Version

3.0.7

License

Apache-2.0

Unpacked Size

34.6 kB

Total Files

8

Last publish

Collaborators

  • socialgroovybot