dimanche 22 mars 2020

Cannot log after tests are done problem in Express App in Jest tests

This is my Jest tests

it('test the endpoint', async done => {
        const request = supertest('http://localhost:3000/myexp');
        request.get('/router1')
        .expect(200)
        .end((err, res) => {
            if(err) {
                throw err;
            } else {
                expect(res.text).toEqual('direct use 1st');
            }
        });
        done();
    })

The test runs successfully, but it said Cannot log after tests are done. Since I sent the HTTP request to the Express App router and it was supposed to log some message like "API got request for [object Object]".

How can I log the message in this case?

Aucun commentaire:

Enregistrer un commentaire