I am using Karma with mocha to test my React components. I have some warnings displayed when the PropTypes are not matched. However it would be really interesting to have these warnings to cause an actual error, as to track down the test and fix it.
Do you know how this could be achieved?
Small improvements to accepted answer:
console.error
instead ofconsole.warn
as spain-train mentioned, added 'Failed prop type' to regex, as only then it works with React 15.3.1, and made the code more strict eslint friendly.You can replace the
console.warn
method with your own and throw when the message provided matches a certain pattern.