addons/isl/integrationTests/setupTests.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318// jest-dom adds custom jest matchers for asserting on DOM nodes.
b69ab319// allows you to do things like:
b69ab3110// expect(element).toHaveTextContent(/react/i)
b69ab3111// learn more: https://github.com/testing-library/jest-dom
b69ab3112import '@testing-library/jest-dom';
b69ab3113
b69ab3114/* eslint-disable no-console */
b69ab3115global.console = require('console');
b69ab3116
b69ab3117jest.mock('@stylexjs/stylex');
b69ab3118
b69ab3119// reduce flakiness by retrying
b69ab3120jest.retryTimes(1);
b69ab3121
b69ab3122import {configure} from '@testing-library/react';
b69ab3123
b69ab3124const IS_CI = !!process.env.SANDCASTLE || !!process.env.GITHUB_ACTIONS;
b69ab3125configure({
b69ab3126 // bump waitFor timeouts in CI where jobs may run slower
b69ab3127 asyncUtilTimeout: IS_CI ? 30_000 : 20_000,
b69ab3128 ...(process.env.HIDE_RTL_DOM_ERRORS
b69ab3129 ? {
b69ab3130 getElementError: (message: string | null) => {
b69ab3131 const error = new Error(message ?? '');
b69ab3132 error.name = 'TestingLibraryElementError';
b69ab3133 error.stack = undefined;
b69ab3134 return error;
b69ab3135 },
b69ab3136 }
b69ab3137 : {}),
b69ab3138});
b69ab3139
b69ab3140global.ResizeObserver = require('resize-observer-polyfill');