【发布时间】:2022-08-23 00:11:28
【问题描述】:
我使用mysql作为数据库,我在互联网上搜索,我尝试的方法不是最新的。我希望数据库在每次测试中自行重置。但是我找不到合适的方法,你能帮忙吗?
describe(\'Authentication System\', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it(\'if user already in database\', async () => {
await request(app.getHttpServer())
.post(\'/auth/signup\')
.send({name:\"muti\"})
.expect(HttpStatus.BAD_REQUEST)
.then((res) => {
const { access_token } = res.body;
expect(access_token).not.toBeDefined();
});
});