You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
When testing html elements that were wrapped in a fragment, we got some unexpected results in the tests. We are using createMount and mount from react-testing
Some things we saw:
Tests would fail if elements were wrapped in <>. In order to make them pass, we has to make it a div.
When doing .html() on a component that's has a fragment. it returned the string of every single element instead of what the DOM looks like.
An example where we saw the first situation failing:
const ChildButton = ({onClick}: {onClick: () => void}) => (
<button type="button" onClick={onClick}>
Clicked
</button>
);
Component that gets mounted:
<>
<div onClick={spy}>
<ChildButton onClick={noop} />
</div>
</>,
tree.find(ChildButton)!.trigger('onClick'); <- Fails with `Attempted to operate on a mounted tree, but the component is no longer mounted`
Another case where we have seen unexpected output is when we use .html() on a component that is wrapped in a react fragment. Using the example below and say page contained the mounted component, when doing a console.log(page.html()) it will return just the text on the buttons. The message displayed through the log is Submit Save draft instead of the DOM
Overview
When testing html elements that were wrapped in a fragment, we got some unexpected results in the tests. We are using
createMount and mount
fromreact-testing
Some things we saw:
<>
. In order to make them pass, we has to make it adiv
..html()
on a component that's has a fragment. it returned the string of every single element instead of what the DOM looks like.An example where we saw the first situation failing:
Another case where we have seen unexpected output is when we use
.html()
on a component that is wrapped in a react fragment. Using the example below and saypage
contained the mounted component, when doing aconsole.log(page.html())
it will return just the text on the buttons. The message displayed through the log isSubmit Save draft
instead of the DOMConsuming repo
SFN
Area
Area: testing
Area: <area>
labels to this issueScope
Package: @shopify/react-testing
Package: <package_name>
label.Checklist
The text was updated successfully, but these errors were encountered: