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

CSF stories using the "story.name" property always fail #190

Open
JohnAlbin opened this issue Dec 6, 2019 · 1 comment
Open

CSF stories using the "story.name" property always fail #190

JohnAlbin opened this issue Dec 6, 2019 · 1 comment

Comments

@JohnAlbin
Copy link

JohnAlbin commented Dec 6, 2019

I have a super simple component which renders perfectly in Storybook 5.2. It uses the CSF format and the "name" property so that I can use a different name from the variable name of the named export.

import React from 'react';
import Error from './index';

export default {
  component: Error,
  title: 'Pages/Error',
}

export const Error404 = () => (
  <Error
    statusCode={404}
  />
);
Error404.story = {
  name: '404 Error',
};

In CSF, the default name for a story is its exported variable name with spaces inserted before camelcase letters or numbers. In this case Error404 is converted to Error 404, but the name I really want is "404 Error" since that is its common terminology. I can't use export const 404Error because that is invalid JavaScript. Fortunately, CSF allows you to override the default export name with the [export var].story.name property.

This option works great inside Storybook. Unfortunately, it causes Loki to fail to make a screenshot saying:

      ❯ Pages/Error
        ✖ 404 Error
          → Failed with "Unable to get position of selector "#root > *". Review the 
            `chromeSelector` option and make sure your story doesn't crash.
…

If I remove the Error404.story.name property, then Loki is able to generate a screenshot without error.

@JohnAlbin JohnAlbin changed the title CSF stories using the "name" parameter always fail CSF stories using the "story.name" property always fail Dec 7, 2019
@JohnAlbin
Copy link
Author

JohnAlbin commented Dec 9, 2019

Update: I just noticed I have another story with TODO.story = { name: "@TODO"} and that renders fine with Loki.

So perhaps it's the use of a space in the name that cause Loki to fail? Edit: Nope. @TODO got converted to TODO which matches the original exported variable name. That just means that most (but not all) stories with [var name].story.name will fail under Loki.

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

No branches or pull requests

1 participant