我正在使用 JEST 对我的快速路线进行单元测试。
在运行 yarn test
时,我的所有测试用例都通过了,但是我得到了一个错误
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
我使用 async
和 done
,但它仍然抛出上述错误。
下面是我的规格代码。请帮助
路线,规划
const request = require('supertest');
describe('Test the root path', () => {
const app = require('./index');
test('GET /gql/gql-communication-portal/release-notes', async (done) => {
const response = await request(app).get('/gql/gql-communication-portal/release-notes');
expect(response.status).toBe(200);
done();
});
});