/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/admin-test-utils/src/after-env.ts
25 строк
1 KB
Ben Irvin
test(front): auto-wrap act; fix rerender with stable data router and auto-wrap act (#25410)
10 фев 2026, 19:56
Не верифицирован
10 фев 2026, 19:56
eac316c
Код
Авторство
О чём код?
import '@testing-library/jest-dom'; import 'jest-styled-components'; import 'whatwg-fetch'; import { act } from '@testing-library/react'; // Note: We set this here because setting it in the config is broken for projects: https://github.com/jestjs/jest/issues/9696 // Also, there are issues with async tests unless it is set at global scope: https://github.com/jestjs/jest/issues/11543 jest.setTimeout(60 * 1000); /** * React Query schedules async notifications which can surface as flaky * "not wrapped in act(...)" warnings in CI. In tests, wrap these notifications * in `act()` so React sees updates as part of the test lifecycle. * * This does not affect production behavior. */ try { // eslint-disable-next-line @typescript-eslint/no-var-requires const { notifyManager } = require('react-query') as typeof import('react-query'); notifyManager.setNotifyFunction((fn) => act(fn)); notifyManager.setBatchNotifyFunction((fn) => act(fn)); } catch { // `react-query` may not be installed for all consumers of @strapi/admin-test-utils. }