generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I was following this tutorial:
https://storybook.js.org/docs/writing-tests/snapshot-testing
But the part where I should import the stories gives me undefined:
import * as Button from './Button.stories.svelte';
const {Primary} = composeStories(Button);The IDE is showing errors on Button and Primary, and debugger shows Button to not have any properties for the stories.
I then tried cloning this repo separately and following:
https://github.com/storybookjs/addon-svelte-csf/blob/main/examples/StoryImporter.mdx
Just to see if I can get any reference to the stories but didn't seem able to.
Steps to reproduce the behavior
git clone [email protected]:storybookjs/addon-svelte-csf.git- run
pnpm iandpnpm build - Create
./examples/x.spec.ts
import { expect, test } from 'vitest';
import * as ExportNameStories from './ExportName.stories.svelte';
test("x", ()=>{
console.log(ExportNameStories);
console.log(ExportNameStories.SimpleName);
console.log(ExportNameStories.NameFromExportName);
})- Edit
vitest.workspace.tsfile to see the x.spec.ts file
Subject: [PATCH] x
---
/vitest.workspace.ts (date 1762011442650)
@@ -12,6 +12,15 @@
},
},
{
+ extends: './vite.config.ts',
+ test: {
+ name: 'asdasdasd',
+ dir: './examples/',
+ environment: 'happy-dom',
+ globals: true,
+ },
+ },
+ {
extends: './vite.config.ts',
plugins: [
storybookTest({
- Run the test.
I expected to see references to the Stories, but I got undefined.
Screenshots and/or logs
Environment
- OS: Linux
- Node.js version: v24.11.0
- NPM version: 11.6.1 (pnpm: 10.18.0)
- Browser (if applicable): N/A
- Browser version (if applicable): N/A
- Device (if applicable): N/A
Additional context
Cloned the repo (main branch) at e73febc
Have I misunderstood how this works, or is this a bug? How should I use stories made with this library for vitest snapshot tests?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working