Add is() and isNot() element identity assertions#2215
Open
NullVoxPopuli-ai-agent wants to merge 1 commit into
Open
Add is() and isNot() element identity assertions#2215NullVoxPopuli-ai-agent wants to merge 1 commit into
is() and isNot() element identity assertions#2215NullVoxPopuli-ai-agent wants to merge 1 commit into
Conversation
Implements the request from mainmatter#2214: assert that the target element is (or is not) the same element as another one, with failure messages that use qunit-dom's element serialization instead of the unhelpful output of `assert.strictEqual(el, otherEl)`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #2214.
Adds two new assertions for comparing the target element against another element by reference, while using qunit-dom's element serialization for readable failure messages:
Previously the only way to assert that two elements are the same node was
assert.strictEqual(el, otherEl), which produces useless failure output for DOM nodes, or piecewisehasAttribute()/hasClass()/hasText()assertions that can't establish identity at all.Details:
is(expected)/isNot(unexpected)compare by reference (===); the failure message serializes both elements (e.g.Element #title is the same element as h2#subtitlewithactual: h1#title,expected: h2#subtitle).is()annotates the actual value with(a different element with the same description)so the failure isn't a confusingx !== xdiff.TypeErrorwhen passed a non-Element, matching the existing conventions for JavaScript users.API.mdregenerated withpnpm docs(the link-reference renumbering accounts for most of the diff there).🤖 Generated with Claude Code