1.2 KB41 lines
Blame
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
12import '@testing-library/jest-dom';
13
14/* eslint-disable no-console */
15global.console = require('console');
16
17jest.mock('@stylexjs/stylex');
18
19// reduce flakiness by retrying
20jest.retryTimes(1);
21
22import {configure} from '@testing-library/react';
23
24const IS_CI = !!process.env.SANDCASTLE || !!process.env.GITHUB_ACTIONS;
25configure({
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
40global.ResizeObserver = require('resize-observer-polyfill');
41