I am testing API for User functionality (signup and login) using jest.
Code for testing:
const request = require('supertest');
const app = require('../../app');
describe('Test User Functionality', () => {
test('User should be able to login', async done => {
const response = await request(app)
.post('/api/users/login')
.send({
email: '[email protected]',
password: 'welcome1',
})
.expect(200);
done();
//expect(response.statusCode).toBe(200);
});
test('User should be able to signup', async done => {
const response = await request(app)
.post('/api/users/signup')
.send({
username: 'testuser',
email: '[email protected]',
password: 'welcome1',
})
.expect(200);
done();
//expect(response.statusCode).toBe(200);
});
});
In case I have single test, it is working fine but with multiple test inside describe, it is showing timeout errors.
Below is the screenshot of the error:
I tried adding timeout, swapping the test but still no success.
Anyone please help !