feat: Add types knex field of global
This commit is contained in:
7
packages/backend/src/types/global.d.ts
vendored
Normal file
7
packages/backend/src/types/global.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { Knex } from 'knex';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
declare namespace globalThis {
|
||||||
|
var knex: Knex;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,12 +1,11 @@
|
|||||||
import { client as knex } from '../../src/config/database';
|
import { client as knex } from '../../src/config/database';
|
||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
global.beforeAll(async () => {
|
global.beforeAll(async () => {
|
||||||
(global as any).knex = knex as Knex;
|
global.knex = knex;
|
||||||
});
|
});
|
||||||
|
|
||||||
global.beforeEach(async function () {
|
global.beforeEach(async function () {
|
||||||
this.transaction = await (global as any).knex.transaction();
|
this.transaction = await global.knex.transaction();
|
||||||
});
|
});
|
||||||
|
|
||||||
global.afterEach(async function () {
|
global.afterEach(async function () {
|
||||||
@@ -14,5 +13,5 @@ global.afterEach(async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
global.afterAll(async () => {
|
global.afterAll(async () => {
|
||||||
(global as any).knex.destroy();
|
global.knex.destroy();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user