mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
test: always exec afterEach in ava test (#4303)
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
@@ -68,7 +68,7 @@ test.beforeEach(async t => {
|
||||
await t.context.app.init();
|
||||
});
|
||||
|
||||
test.afterEach(async t => {
|
||||
test.afterEach.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ test.beforeEach(async () => {
|
||||
auth = module.get(AuthService);
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await module.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import test from 'ava';
|
||||
|
||||
import { Config, ConfigModule } from '../config';
|
||||
|
||||
let config: Config;
|
||||
let module: TestingModule;
|
||||
test.beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
module = await Test.createTestingModule({
|
||||
imports: [ConfigModule.forRoot()],
|
||||
}).compile();
|
||||
config = module.get(Config);
|
||||
});
|
||||
|
||||
test.afterEach.always(async () => {
|
||||
await module.close();
|
||||
});
|
||||
|
||||
test('should be able to get config', t => {
|
||||
t.true(typeof config.host === 'string');
|
||||
t.is(config.env, 'test');
|
||||
|
||||
@@ -40,7 +40,7 @@ test.beforeEach(async () => {
|
||||
await app.init();
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await app.close();
|
||||
await m.close();
|
||||
timer.restore();
|
||||
|
||||
@@ -54,7 +54,7 @@ test.beforeEach(async () => {
|
||||
await app.init();
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ test.beforeEach(async () => {
|
||||
auth = module.get(AuthService);
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await module.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ test.beforeEach(async () => {
|
||||
mail = module.get(MailService);
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ test.beforeEach(async () => {
|
||||
metrics = module.get(Metrics);
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await module.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ test.beforeEach(async t => {
|
||||
t.context.session = session;
|
||||
});
|
||||
|
||||
test.afterEach(async t => {
|
||||
test.afterEach.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ test.beforeEach(async () => {
|
||||
await app.init();
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ test.beforeEach(async () => {
|
||||
await app.init();
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
test.afterEach.always(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ test.beforeEach(async t => {
|
||||
t.context.mail = mail;
|
||||
});
|
||||
|
||||
test.afterEach(async t => {
|
||||
test.afterEach.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ test.beforeEach(async t => {
|
||||
await t.context.app.init();
|
||||
});
|
||||
|
||||
test.afterEach(async t => {
|
||||
test.afterEach.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ test.beforeEach(async t => {
|
||||
t.context.app = app;
|
||||
});
|
||||
|
||||
test.afterEach(async t => {
|
||||
test.afterEach.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user