Turn Off Console Error Messages In A Test
I'm using Jest to test a React component that requires a prop via PropTypes. In one of my tests, I want to test that component when the required prop is excluded. The side effect of doing this is that my test output gets cluttered with the PropType warning.
The thing to do is silence the error message during that test.
We can silence console.error
by temporarily replacing it with a Jest-mocked function and then putting it back at the end of the test.
Last updated