Files
automatisch/packages/backend/test/setup/global-hooks.ts
2023-10-03 23:40:12 +02:00

19 lines
418 B
TypeScript

import { client as knex } from '../../src/config/database';
import { Knex } from 'knex';
global.beforeAll(async () => {
(global as any).knex = knex as Knex;
});
global.beforeEach(async function () {
this.transaction = await (global as any).knex.transaction();
});
global.afterEach(async function () {
await this.transaction.rollback();
});
global.afterAll(async () => {
(global as any).knex.destroy();
});