Skip to content

[Bug]: --index-json flag not honored when running against a local storybook #538

@ronakj

Description

@ronakj

Describe the bug

This is what the readme mentions

If you are running tests against a local Storybook but for some reason want to run in "index.json mode", you can pass the --index-json flag:

yarn test-storybook --index-json

However the code looks something like this (permalink)

const shouldRunIndexJson = runnerOptions.indexJson !== false && !isLocalStorybookIp;

Which will resolve to false even if the flag is passed. This seems like a bug.

The correct code should be

const shouldRunIndexJson = runnerOptions.indexJson === true || (runnerOptions.indexJson !== false && !isLocalStorybookIp);

To Reproduce

You can easily test this using any locally available pre-built storybook. Start a local server using http-server and try to run tests using --index-json flag. It will not be honored and storybook will try to read the storybook configuration which is not needed in index-json mode.

System

NA. Happening in every system.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions