I am setting up some asynchronous junit typescript tests and it seems I don't understand the documentation correctly.
I wrote a test asking a web API for a specific svg image by sending the ID of the image.
The test sends no ID so the web API should return http code 404. This the test and it works well:
test("getSvgByImageId unknown", () => {
expect.assertions(1);
return client.getSvgImageById("")
.then(svg => {
fail("API should return error")
})
.catch(error => {
expect(error.status).toBe(404);
})
});
But why should I use the expect.assertions(x) when I use the fail() method? The test also works without the expect.assertions(x) line.