setupTestFramework.js 679 B

1234567891011121314151617181920212223
  1. // @flow
  2. const consoleError = console.error;
  3. const suppressedErrors = [
  4. 'Error: Could not parse CSS stylesheet',
  5. 'Warning: Use the `defaultValue` or `value` props instead of setting children on <textarea>',
  6. ];
  7. beforeEach(() => {
  8. // Suppress errors from JSDOM CSS parser
  9. // See: https://github.com/jsdom/jsdom/issues/2177
  10. // eslint-disable-next-line flowtype-errors/show-errors
  11. (console: any).error = message => {
  12. if (!suppressedErrors.some(suppressedError => message.includes(suppressedError))) {
  13. consoleError(message);
  14. }
  15. };
  16. });
  17. afterEach(() => {
  18. // eslint-disable-next-line flowtype-errors/show-errors
  19. (console: any).error = consoleError;
  20. });