# jest-environment-knex

> [![Github Master CI Status](https://github.com/SocialGouv/jest-environment-knex/workflows/ci/badge.svg?branch=master)](https://github.com/SocialGouv/jest-environment-knex/actions/) [![codecov](https://codecov.io/gh/SocialGouv/jest-environment-knex/branch/

Latest version **3.0.7** (published 2021-08-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install jest-environment-knex
pnpm add jest-environment-knex
yarn add jest-environment-knex
bun add jest-environment-knex
```

## Health

**Score 35/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.7 |
| Published | 2021-08-30 |
| First published | 2019-07-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 33.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | socialgroovybot |

## Links

- npm: https://www.npmjs.com/package/jest-environment-knex
- Repository: https://github.com/SocialGouv/jest-environment-knex
- Homepage: https://github.com/SocialGouv/jest-environment-knex#readme
- Issues: https://github.com/SocialGouv/jest-environment-knex/issues
- npm.io page: https://npm.io/package/jest-environment-knex

## Dependencies (3)

- [knex](https://npm.io/package/knex.md) ^0.21.21
- [rand-token](https://npm.io/package/rand-token.md) ^1.0.1
- [jest-environment-node](https://npm.io/package/jest-environment-node.md) ^27.0.6

## Recent versions

- 3.0.7 (latest) — 2021-08-30
- 3.0.6 — 2020-11-02
- 3.0.5 — 2020-11-01
- 3.0.4 — 2020-10-29
- 3.0.3 — 2020-10-27
- 3.0.2 — 2020-10-25
- 3.0.1 — 2020-09-27
- 3.0.0 — 2020-09-24
- 2.0.0 — 2020-09-23
- 1.1.14 — 2020-04-21
- 1.1.13 — 2020-03-23
- 1.1.11 — 2020-03-17
- 1.1.9 — 2020-02-26
- 1.1.7 — 2020-01-07
- 1.1.6 — 2019-12-30
- … 8 more at https://npm.io/package/jest-environment-knex/versions

## README

# jest-environment-knex

[![Github Master CI Status](https://github.com/SocialGouv/jest-environment-knex/workflows/ci/badge.svg?branch=master)](https://github.com/SocialGouv/jest-environment-knex/actions/)
[![codecov](https://codecov.io/gh/SocialGouv/jest-environment-knex/branch/master/graph/badge.svg)](https://codecov.io/gh/SocialGouv/jest-environment-knex)
[![NPM version][npm-image]][npm-url]

> [knex](knexjs.org) environment in [Jest](https://github.com/facebook/jest)

Tested against SQlite3 and Postgres. [See `__tests__`](./__tests__)

## Install

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

## Usage

```js
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](https://github.com/SocialGouv/jest-environment-knex/actions) strictly following the [Semantic Versioning](http://semver.org/) specification thanks to [semantic-release](https://github.com/semantic-release/semantic-release).

[npm-url]: https://npmjs.org/package/jest-environment-knex
[npm-image]: http://img.shields.io/npm/v/jest-environment-knex.svg
[travis-url]: http://travis-ci.com/SocialGouv/jest-environment-knex
[travis-image]: http://travis-ci.com/SocialGouv/jest-environment-knex.svg?branch=master

---
_Source: https://npm.io/package/jest-environment-knex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
