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
I tried to hover on a element and then check if another element is being displayed to the user or not, but then I realized that it is not working like that since it waits until the play function is being completely executed. and that is really what makes trouble for me, because I have a play function like this:
import{StoryObj}from"@storybook/react"import{expect}from"@storybook/jest"import{within}from"@storybook/testing-library"import{SomeComponentProps,SomeComponent}from"./some-component"constTemplate: StoryObj<SomeComponentProps>={render: (args)=><SomeComponent{...args}/>,args: {children: "some random info",},}exportconstUnHovered: typeofTemplate={parameters: {pseudo: {hover: false}},args: {children: "You cannot see me!",},play: async({ canvasElement })=>{constcanvas=awaitwithin(canvasElement)awaitretry({attempt: async()=>{constinfoIconContentElement=canvas.getByTestId("someTestId")awaitexpect(infoIconContentElement).not.toBeVisible()},maxRetries: 7,})()},}functionretry({ attempt, maxRetries }: {attempt: (...args: unknown[])=>Promise<unknown>;maxRetries: number}){returnasyncfunction(...args: unknown[]){constslotTime=500letretryCount=0do{try{console.log("Attempting...",Date.now())returnawaitattempt(...args)}catch(error){constisLastAttempt=retryCount===maxRetriesif(isLastAttempt){console.error(error)returnPromise.reject(error)}}constrandomTime=Math.floor(Math.random()*slotTime)constdelay=2**retryCount*slotTime+randomTime// Wait for the exponentially increasing delay period before// retrying again.awaitnewPromise((resolve)=>setTimeout(resolve,delay))}while(retryCount++<maxRetries)}}
And here is the some-component.tsx:
interfaceSomeComponentProps{children: string}exportfunctionSomeComponent({ children }: SomeComponentProps){return(<divclassName="group block"><h3>hover over me</h3><pdata-test="someTestId"className="group-hover:block">{children}</p></div>)}
Anything I am misunderstanding abut this addon or in general how play function and parameters work together?
The text was updated successfully, but these errors were encountered:
Because this addon rewrites your stylesheets rather than toggle the actual browser behavior like DevTools does, it won't render any of the default user agent (browser) styles. Unfortunately there's no JavaScript API to toggle real pseudo states without using a browser extension.
And, but I did not get the message that it will change the UI after play function is executed and probably my tests failed 😢
Hi dear reader
I tried to hover on a element and then check if another element is being displayed to the user or not, but then I realized that it is not working like that since it waits until the play function is being completely executed. and that is really what makes trouble for me, because I have a play function like this:
And here is the
some-component.tsx
:Anything I am misunderstanding abut this addon or in general how play function and parameters work together?
The text was updated successfully, but these errors were encountered: