Sometimes, we want to make a test fail with Jest and JavaScript.
In this article, we’ll look at how to make a test fail with Jest and JavaScript.
How to make a test fail with Jest and JavaScript?
To make a test fail with Jest and JavaScript, we can throw an error in our test.
For instance, we write
test("test", () => {
throw new Error("I have failed you");
});
to throw an Error
object in our test callback to make the test fail.
Conclusion
To make a test fail with Jest and JavaScript, we can throw an error in our test.