Closed
Description
I'd like to configure my testsuite to fail if there are any react warnings triggered.
I'm currently using a variant on this SO answer http://stackoverflow.com/questions/29651950/karma-and-react-have-warnings-to-cause-errors
console.warn = (function(warn) {
return function(msg) {
// Detect react warnings & error
if (/^Warning: /.test(msg)) {
throw new Error("React " + msg);
}
return warn.apply(this, arguments);
};
})(console.warn);
This basically works, but has a problem because there's some global-state memoisation in the code which triggers warning to try not to trigger too often:
Could we provide a way to clear this state, or even better a supported API for opt-in erroring on warnings?