Created
March 13, 2017 21:50
-
-
Save seocam/3670552ceb3b2badcbd491d43f670036 to your computer and use it in GitHub Desktop.
Failing tests when React Warnings are raised
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ERROR_MESSAGES = [ | |
'Warning: React.createElement', | |
'Failed propType:' | |
]; | |
/* Turn console.error messages into failing tests */ | |
console.error = (logger => (...options) => { | |
const [message, ..._rest] = options; | |
ERROR_MESSAGES.forEach(error_message => { | |
if(message.includes(error_message)) { | |
throw new Error(message); | |
} | |
}); | |
logger.apply(logger, options); | |
})(console.error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment