-
Notifications
You must be signed in to change notification settings - Fork 1
[EXPERIMENT] native inspection #27
base: master
Are you sure you want to change the base?
Conversation
This is pretty much how I would like things to work. |
947680d
to
4a1f2fd
Compare
4a1f2fd
to
9e39fa6
Compare
I haven't tackled |
@Anifacted made me aware that the shallow rendered is useful for unit tests. So we should probably keep that around and use htmllike for it. |
It is also an interesting fact that snapshot testing in Jest renders the native elements. |
I find it an intriguing thought that you might be able to test your React components by only looking at the rendered DOM. What would you need, a very thin wrapper around React TestUtils to mount and return the DOM node, use node.querySelector('...') to find stuff. Simulate events using TestUtils. I'm just thinking out the box, don't worry. |
I tried out the idea, it is pretty interesting. With out any fancyness you can achieve the following with test utils and unexpected-dom: describe("when clicking on the close button", () => {
it("closes the sidebar", async () => {
const rendered = findDOMNode(
renderIntoDocument(
<Provider store={store}>
<WorkflowSidebar articleId={String(articles[0].id)} />
</Provider>
)
);
Simulate.click(
rendered.querySelector('[data-test-id="showArticleSettings"]')
);
Simulate.click(
rendered.querySelector('[data-test-id="closeArticleSettings"]')
);
expect(
rendered,
"to contain no elements matching",
'[data-test-id="editSidebar"]'
);
}); |
I by the way found a pretty significant problem with |
Don't take this too seriously. I just wanted to see what would happen if we inspected the rendered output.