DEV Community

Discussion on: Testing NodeJs/Express API with Jest and Supertest

Collapse
 
hotdangca profile image
James Robert Perih

You could:

expect(res.statusCode).toEqual(500);
Enter fullscreen mode Exit fullscreen mode

when you do something intentionally wrong, as well as:

expect(res.body).toEqual('Post not found');
Enter fullscreen mode Exit fullscreen mode

Various other uses of expect here

Collapse
 
nedsoft profile image
Chinedu Orie

Yeah, I've included some failure test cases in the sample project, I'd update the article to reflect it. Thanks for the hints.