setupFramework.ts 1018 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* global process */
  2. import '@visual-snapshot/jest';
  3. import failOnConsole from 'jest-fail-on-console';
  4. // The `@visual-snapshot/jest` package includes these types, but for some reason
  5. // Google Cloud Build's `tsc` fails to include the types (GHA works as expected).
  6. export {};
  7. declare global {
  8. namespace jest {
  9. // eslint complains that R is unused, but we need to match interface,
  10. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  11. interface Matchers<R> {
  12. toSnapshot(): CustomMatcherResult;
  13. }
  14. }
  15. }
  16. process.on('unhandledRejection', reason => {
  17. // eslint-disable-next-line no-console
  18. console.error(reason);
  19. });
  20. failOnConsole({
  21. shouldFailOnWarn: false,
  22. silenceMessage: errorMessage => {
  23. // Ignore the following warnings
  24. if (
  25. /Warning: componentWill(Mount|ReceiveProps) has been renamed/.test(errorMessage)
  26. ) {
  27. return true;
  28. }
  29. if (/HTMLMediaElement.prototype.play/.test(errorMessage)) {
  30. return true;
  31. }
  32. return false;
  33. },
  34. });