This repository was archived by the owner on Sep 5, 2021. It is now read-only.
Test ensuring that elements inspected as they are written#26
Open
sunesimonsen wants to merge 1 commit intomasterfrom
Open
Test ensuring that elements inspected as they are written#26sunesimonsen wants to merge 1 commit intomasterfrom
sunesimonsen wants to merge 1 commit intomasterfrom
Conversation
Collaborator
Author
|
I think this shows pretty well the problem around inspecting the React elements as they are written. If I would like to assert that this structure contains the following: expect(
enzyme.mount(
<ReverseChildren>
<span>One</span>
<span>Two</span>
<span>Three</span>
</ReverseChildren>
),
'to contain',
<div>
<span>Three</span>
<span>Two</span>
<span>One</span>
</div>
);This passes. But if we make it fail: expect(
enzyme.mount(
<ReverseChildren>
<span>One</span>
<span>Two</span>
<span>Three</span>
</ReverseChildren>
),
'to contain',
<div>
<span>Three</span>
<span>Two!</span>
<span>One</span>
</div>
);You get this: expected
<ReverseChildren>
<span>One</span>
<span>Two</span>
<span>Three</span>
</ReverseChildren>
to contain <div><span>Three</span><span>Two!</span><span>One</span></div>
the best match was
One // should be <div><span>Three</span><span>Two!</span><span>One</span></div>That is really unhelpful :-S I would much prefer something like this instead: expected <div><span>Three</span><span>Two</span><span>One</span></div> to contain
<div>
<span>Three</span>
<span>Two!</span>
<span>One</span>
</div>
<div>
<span>Three</span>
<span>
Two // should equal 'Two!'
//
// Two
// Two!
</span>
<span>One</span>
</div> |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This test shows that children in inspected as they are written.