#I like to test component events using storybook how to do so,

1 messages · Page 1 of 1 (latest)

viscid root
#

say I have following code

export const Basic:StoryObj = {
    play:async({canvasElement}) => {
        const canvas = within(canvasElement)
        const InputElem = canvas.getAllByRole('textbox')[0]
        await userEvent.type(InputElem,"This is NFX Basic input with no-props")
        const element = canvas.getByDisplayValue("This is NFX Basic input with no-props")
        expect(element).toBeInTheDocument()
    },
}

I want to make use of actions panel is the motive, thank you for any help. sorry for me being stupid, since docs say that actions - only if one of the args is a function which is triggered by an event

soft schooner
#

<@&1106564915038269622> any ideas folks?

silk drift
#

Did you set up your Storybook with the test runner?

#

Also, based on the screenshot you shared in general: you're looking at the wrong tab. The test runs in interactions tab.

viscid root
#

Please tell me how to run test on components events

#

Say I want to find if the event is triggered

silk drift
#

What do you want to assert?

  1. Check how the DOM updates
  2. If the event handler is passed into the component, then just mock calls
viscid root
#

Bro the example you provided is only for react

viscid root
#

The thing is I have a custom component event which I need to test dispatch of createeventdispatcher

silk drift
#

It's a framework agnostic snippet. The play function is the same