I'm currently utilizing JEST to conduct unit tests on my express routes.
When I run the yarn test
, all of my test cases pass successfully. However, an error occurs:
Jest did not exit one second after the test run has completed.
This typically indicates that there are asynchronous operations lingering in your tests. You may want to consider running Jest with `--detectOpenHandles` for troubleshooting.
Even though I included async
and done
, I still encounter the above error.
Below is the code snippet from my spec file. Any assistance would be greatly appreciated.
routes.spec.ts
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();
});
});