Skip to content

Way to verify that all stories render without errors #515

@Hurtak

Description

@Hurtak

Is your feature request related to a problem? Please describe.

What happened a bunch of time to me is

  1. I had a working stories for some component
  2. I updated the component by adding new required prop - without it the component crashes
  3. I forget to update the stories
  4. Since the stories use the controls Story<Props> type + .args pattern (that is AFAIK the recommended way to do it in the docs) the story crashes

We do have tsc + eslint + ladle build in our CI pipeline and none of these catches that the story is no longer working

Describe the solution you'd like

2 solutions come to my mind

  • have some new command (like ladle verify) that would actually render all of the stories and report if some of them render error?
  • change something with how the story is defined or its types, so that this would get caught on type level?

Additional context

component

export type TestComponentProps = {
  requiredA: () => number;
  requiredB: () => number;
};

export const TestComponent = ({ requiredA, requiredB }: TestComponentProps) => {
  return <h1>a+b = {requiredA() + requiredB()}</h1>;
};

story

export const Test: Story<TestComponentProps> = (props) => <TestComponent {...props} />;
Test.args = {
  requiredA: () => 1,
  // requiredB: () => 2, 
  // ^ if this one is missing, tsc/linter/build passes but the story crashes when rendered
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions