Skip to content

Conversation

@priethor
Copy link
Contributor

@priethor priethor commented Jan 2, 2026

What

Part of #315.

Adds structural assertions to jsx-parser tests that verify the parser produces correct React element output.

Why

PR #331 covered 10 React components in blocks-v3. For most, the mocks were sufficient to test rendered output. But jsx-parser is different: it parses HTML strings into React elements using jQuery DOM methods. The simple jQuery mock in #331 didn't support these, so tests could only verify the parser runs without errors.

This PR enhances the mock to return real DOM nodes, enabling assertions on what the parser actually produces.

How

Enhanced the jQuery mock to parse HTML using DOMParser, enabling assertions on actual output:

const result = parseJSX( '<div class="my-class">Hello</div>' );
expect( result.type ).toBe( 'div' );
expect( result.props.className ).toBe( 'my-class' );
expect( result.props.children ).toBe( 'Hello' );
File Changes
jsx-parser.test.js 35 tests with structural assertions
setup-tests.js Extended wp/acf mocks for parser dependencies
mocks/jquery.js DOM parsing mock using DOMParser
jest.config.js jQuery module mapping

Testing Instructions

npm run test:unit -- tests/js/blocks-v3/
# 174 tests pass

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props priethor.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@priethor priethor mentioned this pull request Jan 2, 2026
22 tasks
@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 30.76%. Comparing base (7551a70) to head (8be93f1).
⚠️ Report is 2 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #341      +/-   ##
============================================
+ Coverage     30.63%   30.76%   +0.12%     
  Complexity     4410     4410              
============================================
  Files           291      291              
  Lines         36918    36918              
============================================
+ Hits          11310    11357      +47     
+ Misses        25608    25561      -47     
Flag Coverage Δ
e2e 42.91% <ø> (-0.51%) ⬇️
javascript 7.36% <ø> (+0.82%) ⬆️
phpunit 28.70% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@priethor priethor force-pushed the ed62-phase-3-pr-13-js branch from 722bb1a to a430f3a Compare January 2, 2026 14:34
Adds structural assertions to jsx-parser tests that verify the parser
produces correct React element output, rather than just checking existence.

- jsx-parser.test.js: 35 tests with structural assertions
- setup-tests.js: Extended wp/acf mocks for parser dependencies
- mocks/jquery.js: DOM parsing mock using DOMParser
- jest.config.js: jQuery module mapping
@priethor priethor force-pushed the ed62-phase-3-pr-13-js branch from a430f3a to 8be93f1 Compare January 2, 2026 14:36
@priethor priethor self-assigned this Jan 2, 2026
@priethor priethor added this to the 6.9.0 milestone Jan 2, 2026
@priethor priethor merged commit 6e94700 into trunk Jan 2, 2026
10 checks passed
@priethor priethor deleted the ed62-phase-3-pr-13-js branch January 2, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants