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();
|
await t.context.app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async t => {
|
test.afterEach.always(async t => {
|
||||||
await t.context.app.close();
|
await t.context.app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ test.beforeEach(async () => {
|
|||||||
auth = module.get(AuthService);
|
auth = module.get(AuthService);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await module.close();
|
await module.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
import { Test } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
|
|
||||||
import { Config, ConfigModule } from '../config';
|
import { Config, ConfigModule } from '../config';
|
||||||
|
|
||||||
let config: Config;
|
let config: Config;
|
||||||
|
let module: TestingModule;
|
||||||
test.beforeEach(async () => {
|
test.beforeEach(async () => {
|
||||||
const module = await Test.createTestingModule({
|
module = await Test.createTestingModule({
|
||||||
imports: [ConfigModule.forRoot()],
|
imports: [ConfigModule.forRoot()],
|
||||||
}).compile();
|
}).compile();
|
||||||
config = module.get(Config);
|
config = module.get(Config);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.afterEach.always(async () => {
|
||||||
|
await module.close();
|
||||||
|
});
|
||||||
|
|
||||||
test('should be able to get config', t => {
|
test('should be able to get config', t => {
|
||||||
t.true(typeof config.host === 'string');
|
t.true(typeof config.host === 'string');
|
||||||
t.is(config.env, 'test');
|
t.is(config.env, 'test');
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ test.beforeEach(async () => {
|
|||||||
await app.init();
|
await app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await app.close();
|
await app.close();
|
||||||
await m.close();
|
await m.close();
|
||||||
timer.restore();
|
timer.restore();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ test.beforeEach(async () => {
|
|||||||
await app.init();
|
await app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await app.close();
|
await app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ test.beforeEach(async () => {
|
|||||||
auth = module.get(AuthService);
|
auth = module.get(AuthService);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await module.close();
|
await module.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ test.beforeEach(async () => {
|
|||||||
mail = module.get(MailService);
|
mail = module.get(MailService);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await app.close();
|
await app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ test.beforeEach(async () => {
|
|||||||
metrics = module.get(Metrics);
|
metrics = module.get(Metrics);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await module.close();
|
await module.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ test.beforeEach(async t => {
|
|||||||
t.context.session = session;
|
t.context.session = session;
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async t => {
|
test.afterEach.always(async t => {
|
||||||
await t.context.app.close();
|
await t.context.app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ test.beforeEach(async () => {
|
|||||||
await app.init();
|
await app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await app.close();
|
await app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ test.beforeEach(async () => {
|
|||||||
await app.init();
|
await app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach.always(async () => {
|
||||||
await app.close();
|
await app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ test.beforeEach(async t => {
|
|||||||
t.context.mail = mail;
|
t.context.mail = mail;
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async t => {
|
test.afterEach.always(async t => {
|
||||||
await t.context.app.close();
|
await t.context.app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ test.beforeEach(async t => {
|
|||||||
await t.context.app.init();
|
await t.context.app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async t => {
|
test.afterEach.always(async t => {
|
||||||
await t.context.app.close();
|
await t.context.app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ test.beforeEach(async t => {
|
|||||||
t.context.app = app;
|
t.context.app = app;
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async t => {
|
test.afterEach.always(async t => {
|
||||||
await t.context.app.close();
|
await t.context.app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user