This is an example of how to use the shouldFailOnAssert
option of jest-fail-on-console
- Installing it in
package.json
- Adding a
jest.config.js
file that setssetupFilesAfterEnv
- Adding a
jest.setup.js
file that callsfailOnConsole({ shouldFailOnAssert: true })
Look at index.js. Note that we have two methods, assertSuccess and assertFailure. When we call assertSuccess, that doesn't fail the test because 1 === 1
, but when we call assertFailure
, the test is failed. This is because console.assert
doesn't log in assertSuccess
, but it does in assertFailure
.
One of the tests, test client › asserts failure
, fails to show you how errors are display.