setupFramework.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* global process */
  2. import failOnConsole from 'jest-fail-on-console';
  3. process.on('unhandledRejection', reason => {
  4. // eslint-disable-next-line no-console
  5. console.error(reason);
  6. });
  7. failOnConsole({
  8. shouldFailOnWarn: false,
  9. silenceMessage: errorMessage => {
  10. // Ignore the following warnings
  11. if (
  12. /Warning: componentWill(Mount|ReceiveProps) has been renamed/.test(errorMessage)
  13. ) {
  14. return true;
  15. }
  16. if (/HTMLMediaElement.prototype.play/.test(errorMessage)) {
  17. return true;
  18. }
  19. // This warning was removed in React 18, can be ignored in most cases
  20. // https://github.com/reactwg/react-18/discussions/82
  21. if (
  22. /Warning: Can't perform a React state update on an unmounted component/.test(
  23. errorMessage
  24. )
  25. ) {
  26. return true;
  27. }
  28. // TODO: Remove this after updating jsdom, currently it cannot handle @container queries
  29. if (/Error: Could not parse CSS stylesheet/.test(errorMessage)) {
  30. return true;
  31. }
  32. return false;
  33. },
  34. });