Skip to content

Keep React's act() environment on in the block editor tests - #154

Merged
erseco merged 1 commit into
mainfrom
fix/rtl-act-environment
Sep 29, 2026
Merged

erseco merged 1 commit into
mainfrom
fix/rtl-act-environment

Conversation

@erseco

@erseco erseco commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #153. @testing-library/react only turns on React's act() environment (IS_REACT_ACT_ENVIRONMENT) when it finds global beforeAll/afterAll hooks. With globals: false the suite imports them from vitest, so the flag was no longer set in tests/js/elp_upload.test.js, and React state updates were not flushed inside act().

On main this changed no result or coverage number, but on the feature/secure-iframe-sandbox branch (#56), whose tests open the export menu, it silently dropped assets/js/elp-upload.js from 66.16% to 58.64% lines: the menu body never rendered, yet the tests still passed. Setting the flag in the test file restores the previous behaviour; with it the branch is back to 66.16%.

Testing

npm run test:js: 258/258, 95.84% lines, same as before.

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.
@github-actions

Copy link
Copy Markdown
Contributor

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELP upload, shortcode, Gutenberg block and preview work normally.

@codecov-commenter

codecov-commenter commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.43%. Comparing base (5e40e52) to head (8e87a6a).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #154   +/-   ##
=========================================
  Coverage     96.43%   96.43%           
  Complexity      806      806           
=========================================
  Files            36       36           
  Lines          4238     4238           
=========================================
  Hits           4087     4087           
  Misses          151      151           
Flag Coverage Δ
javascript 95.84% <ø> (ø)
php 96.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erseco
erseco merged commit eaf1968 into main Sep 29, 2026
5 checks passed
@erseco
erseco deleted the fix/rtl-act-environment branch September 29, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants