Skip to content

fake-knex-client 1.1.1

Install from the command line:
Learn more about npm packages
$ npm install @myrotvorets/fake-knex-client@1.1.1
Install via package.json:
"@myrotvorets/fake-knex-client": "1.1.1"

About this version

fake-knex-client

Fake Client for Knex.js

Usage

import * as knexpkg from 'knex';
import mockKnex from 'mock-knex';
import { FakeClient } from '@myrotvorets/fake-knex-client';

describe('...', function () {
    let db: knexpkg.Knex;

    before(function () {
        const { knex } = knexpkg.default;
        db = knex({ client: FakeClient });
        mockKnex.mock(db);
    });

    // ...
});

Why

We discovered that our integration tests, which involve a real database, don't work smoothly alongside our functional tests that use mock-knex with the actual database driver when we employ mocha as our test runner. This issue likely arises because mocha, unlike jest, doesn't isolate each test, resulting in some unexpected behavior.

One potential solution we considered was to utilize a distinct database driver for functional tests, such as better-sqlite3. However, this approach would introduce a significant and unnecessary dependency to our project.

Details


Assets

  • fake-knex-client-1.1.1.tgz

Download activity

  • Total downloads 7,360
  • Last 30 days 491
  • Last week 64
  • Today 7

Recent versions

View all