setupFramework.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // TODO: Remove after either the removal of AsyncComponent or migrating the tests not to use contexts
  33. if (
  34. /uses the legacy contextTypes API which is no longer supported/.test(errorMessage)
  35. ) {
  36. return true;
  37. }
  38. return false;
  39. },
  40. });