feat: Add global hooks for jest
This commit is contained in:
17
packages/backend/test/setup/global-hooks.ts
Normal file
17
packages/backend/test/setup/global-hooks.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { client as knex } from '../../src/config/database';
|
||||
|
||||
global.beforeAll(async () => {
|
||||
global.knex = knex;
|
||||
});
|
||||
|
||||
global.beforeEach(async function () {
|
||||
this.transaction = await global.knex.transaction();
|
||||
});
|
||||
|
||||
global.afterEach(async function () {
|
||||
await this.transaction.rollback();
|
||||
});
|
||||
|
||||
global.afterAll(async () => {
|
||||
global.knex.destroy();
|
||||
});
|
Reference in New Issue
Block a user