setupFramework.ts 799 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* global process */
  2. import failOnConsole from 'jest-fail-on-console';
  3. process.on('unhandledRejection', reason => {
  4. console.error(reason);
  5. });
  6. failOnConsole({
  7. shouldFailOnWarn: false,
  8. silenceMessage: errorMessage => {
  9. // Ignore the following warnings
  10. if (
  11. /Warning: componentWill(Mount|ReceiveProps) has been renamed/.test(errorMessage)
  12. ) {
  13. return true;
  14. }
  15. if (/HTMLMediaElement.prototype.play/.test(errorMessage)) {
  16. return true;
  17. }
  18. // This warning was removed in React 18, can be ignored in most cases
  19. // https://github.com/reactwg/react-18/discussions/82
  20. if (
  21. /Warning: Can't perform a React state update on an unmounted component/.test(
  22. errorMessage
  23. )
  24. ) {
  25. return true;
  26. }
  27. return false;
  28. },
  29. });