Conditional rendering in visual tests
See original GitHub issueHow can I show conditionally rendered elements in the visual tests?
or…
How can get visual tests of my components, AFTER the play function has run?
Is there a possible way to do this?
or do I need to create an HOC that handles the state/clickaway… and passes a open=true/false to the inner component?
So I can just write a story for the LOC and switch out the open prop?
Canvas
Snapshot
Open State code
Open.play = async ({ canvasElement }) => {
const canvas = within(canvasElement)
await userEvent.click(canvas.getByTestId('ButtonMenuCheckbox-button'))
const menu = await waitFor(
() => screen.getByTestId('ButtonMenuCheckbox-menu--loaded'),
{ timeout: 1000, interval: 2000 }
)
waitFor(() => screen.getByTestId('ButtonMenuCheckbox-menu--loaded'), {
timeout: 2000,
interval: 2000,
})
expect(menu).toBeTruthy()
}
Note: There is a 100ms opacity transition on the popper menu that I am trying to also get around. Any tips on this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
React Conditional Rendering Techniques & Best Practices
Here are a few methods you can use to render React components: If Else conditional operator import React from 'react'; import ReactDOM from...
Read more >Conditional Rendering in Vue - Telerik
Let's take a look at three Vue directives for conditional rendering: v-if, v-else and v-else-if. In this post, we will look at how...
Read more >Visualforce to LWC: Conditional Rendering
Conditional Rendering is used to show or hide a particular block based on a condition. If you take a look at the below...
Read more >Conditional rendering tactics for React components
A simple exploration and comparison of two tactics for handling conditionally rendering components in React.
Read more >Conditional rendering in React | Ben Ilegbodu
It's more common, however, to do the conditional rendering within the context of the JSX. And probably the most common inline approach is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like that did the trick, but now my float: right is not working in Chromatic… only in Storybook (which I will eventually fix using your helper)
Thanks!