Accessing storybook csf metadata for external tooling #28195
-
SummaryHi, I'm just wondering what the recommended way is to access storybook csf metadata for use outside of storybook. The use case is to generate Playwright VRTs for all stories in a file (once we have the id we can visit the correct url and take a screenshot). The current approach we're taking is to build the storybook and use the Note: we have tried the new Playwright Component testing but it currently won't fully work with our setup due to issues with bundlers. Thanks any help greatly appreciated! Additional informationNo response Create a reproductionNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
I am doing it the same way. I have set the id attribute on every stories meta (or story level), so I have a list of static IDs that don't change when moving files. To make the screenshots better, I am using the id to populate the link that you'll get when you open the story without storybooks ui. Every Story I want to test is then a fixture setup. Instead of the index.json which I think is totally fine you could of course set the stories IDs to like an ascending number + component name or something. With tools like crawlee you could also visit all urls in a site automatically. |
Beta Was this translation helpful? Give feedback.
-
@allforabit we consider We also have an API |
Beta Was this translation helpful? Give feedback.
-
@shilman Thanks for this! I have 2 questions:
|
Beta Was this translation helpful? Give feedback.
@allforabit we consider
index.json
to be an API and it has a version keyv
that we bump any time there's a breaking change. I recently bumped it in a minor release so it's not semver. But if your script checks the version, it should be fine to use. And I don't expect any changes that would affect you in the foreseeable future.We also have an API
@storybook/csf-tools
that can be used to analyze CSF in code. but i would recommend index.json unless you need more flexibility.