Merge pull request #17932 from strapi/chore/improve-test-logging

chore(admin-test-utils): swallow styled-components transient errors
This commit is contained in:
Gustav Hansen 2023-09-05 15:20:51 +02:00 committed by GitHub
commit 0ae34ba59b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,12 +35,19 @@ const error = console.error;
window.console = {
...window.console,
error(...args: any[]) {
error(...args);
const message = format(...args);
if (/(Invalid prop|Failed prop type)/gi.test(message)) {
throw new Error(message);
// Ignore errors thrown by styled-components. This can be removed once we upgrade
// to styled-components@6 and have separate props that are rendered in the DOM by
// the ones that aren't using the $ prefix.
// https://styled-components.com/docs/faqs#transient-as-and-forwardedas-props-have-been-dropped
} else if (/React does not recognize the .* prop on a DOM element/.test(message)) {
// do nothing
} else {
error(...args);
}
},
};