Reputation: 1730
How to make this sort of test fail in Jest? Is there a global setting for making any test with a failed-assert fail in Jest?
test('Assert', () =>
{
console.assert(false, "This should fail the test");
});
Upvotes: 0
Views: 676
Reputation: 9303
This issue has been discussed here: https://github.com/facebook/jest/issues/5634
The suggestions include checking your environment or node version. If that doesn't work, you can add the following to your test setup file:
console.assert = (statement, message) => {
if (!statement) throw new Error(message);
};
Upvotes: 1