Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Sep 20, 2023
1 parent a8f167f commit 849acb4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# fake-knex-client

Fake Client for Knex.js

## Usage

```typescript
import * as knexpkg from 'knex';
import mockKnex from 'mock-knex';
import { FakeClient } from '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.

0 comments on commit 849acb4

Please sign in to comment.