feat: Add types knex field of global

This commit is contained in:
Faruk AYDIN
2023-10-01 23:40:25 +02:00
parent 3703390268
commit 04a78ee0ba
2 changed files with 10 additions and 4 deletions

View File

@@ -0,0 +1,7 @@
import { Knex } from 'knex';
declare global {
declare namespace globalThis {
var knex: Knex;
}
}

View File

@@ -1,12 +1,11 @@
import { client as knex } from '../../src/config/database';
import { Knex } from 'knex';
global.beforeAll(async () => {
(global as any).knex = knex as Knex;
global.knex = knex;
});
global.beforeEach(async function () {
this.transaction = await (global as any).knex.transaction();
this.transaction = await global.knex.transaction();
});
global.afterEach(async function () {
@@ -14,5 +13,5 @@ global.afterEach(async function () {
});
global.afterAll(async () => {
(global as any).knex.destroy();
global.knex.destroy();
});