Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kolenov/a794a8fb95d4727ec63455076a870635 to your computer and use it in GitHub Desktop.
Save Kolenov/a794a8fb95d4727ec63455076a870635 to your computer and use it in GitHub Desktop.
const originalConsoleError = console.error;
console.error = message => {
if (/(Failed prop type)/.test(message)) {
throw new Error(message);
}
originalConsoleError(message);
};
@Kolenov
Copy link
Author

Kolenov commented Jul 11, 2022

{
  "jest": {
    "setupFiles": [
      "<rootDir>/scripts/throw-on-prop-type-error.js"
    ]
  }
}

The setupFiles is not exposed by default when the app is created using create-react-app. So, the tests will not run at all.
The alternative is to include the contents of throw-on-prop-type-error.js to src/setupTests.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment