Skip to content

fix: ignore attribute order in toContainHTML - #732

Open
Hashim1999164 wants to merge 1 commit into
testing-library:mainfrom
Hashim1999164:fix/to-contain-html-attribute-order
Open

fix: ignore attribute order in toContainHTML#732
Hashim1999164 wants to merge 1 commit into
testing-library:mainfrom
Hashim1999164:fix/to-contain-html-attribute-order

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 26, 2026

Copy link
Copy Markdown

Summary

Test plan

  • FORCE_COLOR=1 CI=true npm test -- --testPathPattern=to-contain-html --coverage=false --watchAll=false
  • Added regression test for opposite attribute orders on the same element

Normalize HTML by sorting attributes before comparing so matches are
not sensitive to attribute order, and error output stays consistent.
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.

expect.toContainHTML() is sensitive to attribute order, but attributes are reordered in error message

1 participant