Storybook: How to get a list of stories during a build step?

Created on 15 Apr 2017  路  4Comments  路  Source: storybookjs/storybook

I am setting up Backstopjs for visual diff regression testing and want to automatically run a visual test for every Storybook story.

It looks like I can only use the client API to retrieve stories at runtime, after the app has run and stories have been added. But I need to generate the list of URLs statically in a build step. A few ideas how this could be solved:

  1. Static analysis of my story files, just run a regex on the source as text. This would be brittle and would be harder to share the code with others.
  2. Extend the static build to also create a .json file containing kinds with child story names.

Maybe there's something else more obvious I haven't thought of? Thoughts? Thanks!

has workaround question / support

Most helpful comment

@swese44 , hi
did you solve your problem? If yes, could you share the way how you do it?

All 4 comments

@swese44 , hi
did you solve your problem? If yes, could you share the way how you do it?

Can we re-open this ticket?

It would be a super handy if Storybook could output a list of stories into a .json file. Not just for visual regression testing, I'd imagine.

Edit: I've decided to create a new ticket and reference this one since this ticket was marked as a support request. BTW, the link to the "has workaround" is broken, so it's impossible to find the work-around now.

In 5.2 we've introduced CSF which is a declarative format for defining stories.

In 5.3 we'll introduce tri-config which will make it possible for defining stoy-files declaratively too.

These 2 things together will make it possible -in theory- to generate a JSON file during the bundle-phase.

So work is being done to make this possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rpersaud picture rpersaud  路  3Comments

wahengchang picture wahengchang  路  3Comments

xogeny picture xogeny  路  3Comments

purplecones picture purplecones  路  3Comments

miljan-aleksic picture miljan-aleksic  路  3Comments