Skip to content

Instantly share code, notes, and snippets.

@seocam
Created March 13, 2017 21:50
Show Gist options
  • Save seocam/3670552ceb3b2badcbd491d43f670036 to your computer and use it in GitHub Desktop.
Save seocam/3670552ceb3b2badcbd491d43f670036 to your computer and use it in GitHub Desktop.
Failing tests when React Warnings are raised
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