Skip to content

[Bug]: Components using Superforms cannot be tested #33254

@Stadly

Description

@Stadly

Describe the bug

If you have a component using Superforms, testing it with @storybook/addon-vitest does not work, both when running the tests on the command line and from the Storybook UI. In the interactions panel, things work as expected.

Image Image

Reproduction link

https://stackblitz.com/edit/github-mvcrdt2n?file=src%2Fstories%2FButton.svelte

Reproduction steps

Using the provided StackBlitz:

  1. Open https://stackblitz.com/edit/github-mvcrdt2n?file=src%2Fstories%2FButton.svelte
  2. Run the tests either from the UI or using vitest run.

Manual reproduction:

  1. npm i -D sveltekit-superforms
  2. Add import to one of your components for which you have stories with play functions: import { superForm } from "sveltekit-superforms";
  3. Initialize Superforms in the script tag: const form = superForm({ foo: "" });
  4. Run your story tests

System

│  System:
│  OS: Linux 5.0 undefined
│  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
│  Shell: 1.0 - /bin/jsh
│  Binaries:
│  Node: 20.19.1 - /usr/local/bin/node
│  Yarn: 1.22.19 - /usr/local/bin/yarn
│  npm: 10.8.2 - /usr/local/bin/npm <----- active
│  pnpm: 8.15.6 - /usr/local/bin/pnpm

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions