storybookjs / test-runner

🚕 Turn stories into executable tests
https://storybook.js.org/docs/writing-tests/interaction-testing
MIT License
220 stars 66 forks source link

[bug] should not require main.js on standalone remote mode #451

Closed zb-sj closed 1 month ago

zb-sj commented 2 months ago

Describe the bug

Hi, I'm trying to leverage test-runner to do some e2e screenshot generation on aws lambda.

As far as I know, main.js configurations aren't or shouldn't be required for remote standalone testing that was implemented at #31

In fact, I could run my test just fine with random main.js like:

// copied straight from the document
const config = {
  // Required
  // Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
  framework: '@storybook/your-framework',
  stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
  // Optional
  addons: ['@storybook/addon-essentials'],
  docs: {
    autodocs: 'tag',
  },
  staticDirs: ['../public'],
};
export default config;

This is the stderr if no main.js is provided:

[test-storybook] Detected a remote Storybook URL, running in index json mode. To disable this, run the command again with --no-index-json

[test-storybook] Could not load main.js in .storybook. Is the ".storybook" config directory correct? You can change it by using --config-dir <path-to-dir>

To Reproduce Steps to reproduce the behavior:

  1. Run npx test-storybook --url $STORYBOOK_URL --no-cache on any non-storybook environment

Expected behavior

it should run just fine without .storybook/main.js

Additional context

https://github.com/storybookjs/test-runner/issues/23

yannbf commented 1 month ago

Hey @zb-sj well said, that makes total sense and is a bug. I'm fixing it! Thanks for reporting!