jest-prop-type-error
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,9 +0,9 @@ | ||
const originalConsoleError = console.error; | ||
const error = console.error; | ||
console.error = message => { | ||
if (/(Failed prop type)/.test(message)) { | ||
console.error = (message, ...args) => { | ||
if (/(Invalid prop|Failed prop type)/gi.test(message)) { | ||
throw new Error(message); | ||
} | ||
originalConsoleError(message); | ||
error.apply(console, [message, ...args]); | ||
}; |
{ | ||
"name": "jest-prop-type-error", | ||
"description": "Makes Jest throw on React prop-type failures", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "author": "Espen Henriksen", |
@@ -14,3 +14,5 @@ # jest-prop-type-error | ||
whenever a wrong prop is passed to a component, the prop-type validation would | ||
pick this up and fail the test. Then we would be able to | ||
pick this up and fail the test. Then we would be able to verify that the props | ||
that are passed to our components are good compile-time, provided the tests | ||
run when we build our production bundle. | ||
@@ -45,5 +47,5 @@ That is what this library does! | ||
[pt]: https://facebook.github.io/react/docs/typechecking-with-proptypes.html | ||
[blog]: | ||
[blog]: https://medium.com/shark-bytes/type-checking-with-prop-types-in-jest-e0cd0dc92d5 | ||
[react]: https://reactjs.org/ | ||
[jest]: https://facebook.github.io/jest/ | ||
[stian]: https://twitter.com/stipsan |
8342
7
50