Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Created December 19, 2017 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonewebdesign/34aec555cff100accbf0e308e1230097 to your computer and use it in GitHub Desktop.
Save simonewebdesign/34aec555cff100accbf0e308e1230097 to your computer and use it in GitHub Desktop.
React PropTypes as mocha unit test errors
// Override console.error to run tests
const _console_error = console.error;
console.error = function (msg) {
if (/^Warning: Failed prop type:/.test(msg)) {
it('should pass PropType validation', () => {
throw new AssertionError(msg);
});
}
// Call the real console.error
return _console_error.apply(console, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment