Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][legacy - v4] "[Function handler] is not a spy or a call to a spy" in play #211

Open
AliceLeRaptor opened this issue Sep 10, 2024 · 0 comments
Labels
bug Something isn't working legacy Related to the legacy version(s)

Comments

@AliceLeRaptor
Copy link

AliceLeRaptor commented Sep 10, 2024

Describe the bug

When using latest Storybook version (8.2.9) and latest addon-svelte-csf version (4.1.7) I have this error displayed in the interaction tab of my stories, when making assertions on events.

[Function handler] is not a spy or a call to a spy!

This error disappears when reloading the story or navigating to it. It only shows when the story is rendered for the first time.

Steps to reproduce the behavior

  1. Create a svelte library project with npm create svelte@latest myapp, then add Storybook with npx storybook@latest init
  2. Create a new component and story using templates provided by this addon documentation (remove the existing Button component and story or give a different name to the new component / story)
  3. In any story from the new stories.svelte file, add a simple play function with an assertion on an event :
  <Story name="Rounded" args={{rounded: true}} play={async ({ canvasElement, args }) => {
    const { getByRole } = within(canvasElement);
    await userEvent.click(getByRole('button'));
    expect(args.event_click).toHaveBeenCalled();
  }}/>
  1. Run storybook with npm run storybook and go to the story you eddited. In the interaction tab you should see the error
    [Function handler] is not a spy or a call to a spy!
  2. Reload the story or navigate to another one then navigate back to the story, the error should be gone and the interaction tests should pass without errors.

Expected behavior

I expect the test in the play function to run without errors. This behavior happens when reloading the story.

Screenshots and/or logs

This is what I get when I console.log args inside the play function before reloading the story :

Screenshot from 2024-09-10 12-06-53

When reloading the story and everything is working fine, the log displays a proper spy :

Screenshot from 2024-09-10 12-09-30

Environment

  • OS: Ubuntu
  • Node.js version: v20.14.0
  • NPM version: 10.7.0
  • Browser (if applicable): Firefox / Chromium
  • Browser version (if applicable): 129.0.2 for Firefox, 127.0.6533.119 for Chromium
@AliceLeRaptor AliceLeRaptor added the bug Something isn't working label Sep 10, 2024
@xeho91 xeho91 changed the title [Bug] "[Function handler] is not a spy or a call to a spy" in play [Bug][legacy - v4] "[Function handler] is not a spy or a call to a spy" in play Nov 5, 2024
@xeho91 xeho91 added the legacy Related to the legacy version(s) label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working legacy Related to the legacy version(s)
Projects
None yet
Development

No branches or pull requests

2 participants