| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | // jest-dom adds custom jest matchers for asserting on DOM nodes. |
| 9 | // allows you to do things like: |
| 10 | // expect(element).toHaveTextContent(/react/i) |
| 11 | // learn more: https://github.com/testing-library/jest-dom |
| 12 | import '@testing-library/jest-dom'; |
| 13 | |
| 14 | /* eslint-disable no-console */ |
| 15 | global.console = require('console'); |
| 16 | |
| 17 | jest.mock('@stylexjs/stylex'); |
| 18 | |
| 19 | // reduce flakiness by retrying |
| 20 | jest.retryTimes(1); |
| 21 | |
| 22 | import {configure} from '@testing-library/react'; |
| 23 | |
| 24 | const IS_CI = !!process.env.SANDCASTLE || !!process.env.GITHUB_ACTIONS; |
| 25 | configure({ |
| 26 | // bump waitFor timeouts in CI where jobs may run slower |
| 27 | asyncUtilTimeout: IS_CI ? 30_000 : 20_000, |
| 28 | ...(process.env.HIDE_RTL_DOM_ERRORS |
| 29 | ? { |
| 30 | getElementError: (message: string | null) => { |
| 31 | const error = new Error(message ?? ''); |
| 32 | error.name = 'TestingLibraryElementError'; |
| 33 | error.stack = undefined; |
| 34 | return error; |
| 35 | }, |
| 36 | } |
| 37 | : {}), |
| 38 | }); |
| 39 | |
| 40 | global.ResizeObserver = require('resize-observer-polyfill'); |
| 41 | |