Created
December 19, 2017 12:05
-
-
Save simonewebdesign/34aec555cff100accbf0e308e1230097 to your computer and use it in GitHub Desktop.
React PropTypes as mocha unit test errors
This file contains 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
// 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