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

Portable stories - Create compose functions for Svelte #25878

Open
Tracked by #25875
yannbf opened this issue Feb 2, 2024 · 2 comments · Fixed by #26349
Open
Tracked by #25875

Portable stories - Create compose functions for Svelte #25878

yannbf opened this issue Feb 2, 2024 · 2 comments · Fixed by #26349

Comments

@yannbf
Copy link
Member

yannbf commented Feb 2, 2024

Currently there are testing APIs (composeStory, composeStories, setProjectAnnotations) for React and Vue3, but not for Svelte.

Here's a reference on how it's done for Vue3:
https://github.com/storybookjs/storybook/blob/4a6df46b1ab32fa9f8c2b82703a235b158460b14/code/renderers/vue3/src/testing-api.ts

And React:
https://github.com/storybookjs/storybook/blob/645439adfbb543b5dadb28a471f2da7166c1c6b1/code/renderers/react/src/testing-api.ts

@theetrain
Copy link

Hello, I saw this in the docs and I'm confused about this part in the example:

import { test, expect } from 'vitest';
import { screen } from '@testing-library/svelte';
import { composeStories } from '@storybook/svelte';
 
// Import all stories and the component annotations from the stories file
import * as stories from './Button.stories';
 
// Every component that is returned maps 1:1 with the stories,
// but they already contain all annotations from story, meta, and project levels
const { Primary, Secondary } = composeStories(stories);

What does Primary look like in this example's Button.stories.svelte? Also is the .svelte extension needed as part of the import?

https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#composestories

@JReinhold
Copy link
Contributor

This feature is currently only supported with .stories.ts files (even in Svelte), and not with .stories.svelte from the Svelte CSF addon. Were hoping to tackle that in the next minor release. See storybookjs/addon-svelte-csf#213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants