I'm using Supertest and Jest to test a Node.js API.
A sample test has the following format
it('Read a note for a user', (done) => {
request(graphqlURL)
.post('/graphql')
.set(baseHeaders())
.send({
query: graphQLQuery
})
.end((err, res) => {
expect(res.status).toBe(200);
done();
})
});
Currently when the expectation fails, the following gets logged
expect(received).toBe(expected) // Object.is equality
Expected: 200
Received: 404
I'd also like to log the request and the response alongside the failed tests to have more context while debugging.
Is there a way to print those as well, only for the tests which are failing?