Skip to content

Commit

Permalink
Silence Jest errors
Browse files Browse the repository at this point in the history
- since Jest is neither SSR or browser rendering, it really doesn't need to care about these errors
  • Loading branch information
cee-chen committed May 23, 2022
1 parent 49b78b6 commit db0b25a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion scripts/jest/setup/throw_on_console_error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// Fail if a test ends up `console.error`-ing, e.g. if React logs because of a
// failed prop types check.
console.error = message => {
console.error = (message) => {
// @see https://github.com/emotion-js/emotion/issues/1105
// This error that Emotion throws doesn't apply to Jest, so
// we're just going to straight up ignore the first/nth-child warning
if (
typeof message === 'string' &&
message.includes('The pseudo class') &&
message.includes(
'is potentially unsafe when doing server-side rendering. Try changing it to'
)
) {
return;
}

throw new Error(message);
};

0 comments on commit db0b25a

Please sign in to comment.