From 8e87a6af1aaa8656214c28c9db81790f5f0a3cf9 Mon Sep 17 00:00:00 2001 From: erseco Date: Tue, 29 Sep 2026 03:33:35 +0100 Subject: [PATCH] Keep React's act() environment on in the block editor tests Testing Library only sets IS_REACT_ACT_ENVIRONMENT when it finds global beforeAll/afterAll hooks. Since the suite imports them from vitest, the flag was left off and React state updates were no longer flushed inside act(), so some rendering paths silently stopped running. --- tests/js/elp_upload.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/js/elp_upload.test.js b/tests/js/elp_upload.test.js index becb5aa..ce4c161 100644 --- a/tests/js/elp_upload.test.js +++ b/tests/js/elp_upload.test.js @@ -23,6 +23,11 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from const path = require( 'path' ); const { pathToFileURL } = require( 'url' ); const { render, screen, fireEvent, cleanup } = require( '@testing-library/react' ); + +// Testing Library only turns on React's act() environment when it finds global +// beforeAll/afterAll hooks. The suite imports them from vitest instead, so the +// flag is set here; without it state updates are not flushed inside act(). +globalThis.IS_REACT_ACT_ENVIRONMENT = true; const element = require( '@wordpress/element' ); const blocks = require( '@wordpress/blocks' ); const components = require( '@wordpress/components' );