setupFramework.ts 840 B

123456789101112131415161718192021222324252627282930313233343536
  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. return false;
  29. },
  30. });