Get the answers you need at Westonci.ca, where our expert community is dedicated to providing you with accurate information. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

I'm using JEST for unit testing my express routes.
While running the yarn test all my test case are getting passed, but I'm getting an error.
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.
I used async & done, but still it throws the above error.
Below is my spec code:
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();
});
});


Sagot :

Thanks for stopping by. We are committed to providing the best answers for all your questions. See you again soon. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.