storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.22k stars 9.26k forks source link

Shoryshot-puppeteer --allow-file-access-from-files flag #10962

Closed Bruno-Tavares-Bose closed 4 years ago

Bruno-Tavares-Bose commented 4 years ago

Describe the bug Trying to run Storyshots (image snapshots) with a file://... in a project with SVG (for example) is not possible.

To Reproduce Steps to reproduce the behavior:

  1. Having a project with SVG assets to be used in href (in icons for instance)
  2. Setup jest and storyshots/storyshots-puppeteer to run visual regression tests
  3. Having you storybookUrl point to your static storybook (file:///${path.resolve(__dirname, 'path/to/storybook-static'))
  4. Check your images_snapshots "icons" components

Expected behavior Those images should have our SVGs.

Code snippets

initStoryshots({
    test: imageSnapshot({
        storybookUrl: `file:///${path.resolve(__dirname, 'storybook-static')}`
    }),
...

System:

Environment Info:

  System:
    OS: macOS 10.15.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.22.0 - ~/.nvm/versions/node/v12.16.1/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
  Browsers:
    Chrome: 83.0.4103.61
    Safari: 13.1
  npmPackages:
    @storybook/addon-a11y: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/addon-actions: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/addon-docs: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/addon-storyshots: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/addon-storyshots-puppeteer: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/addons: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/react: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/theming: 6.0.0-beta.17 => 6.0.0-beta.17 
    @storybook/vue: 6.0.0-beta.17 => 6.0.0-beta.17

Additional context Changing this line to have --allow-file-access-from-files flag, fix the issue. Therefore, we may want to have this args to be set up (like we have executablePath already) or having a specific flag to add this flag (I would not recommend adding it by default since it is a dangerous one...)

csardinha commented 4 years ago

There are other situations (e.g. storybook-dark-mode that changes the iframe body class from the outside of the iframe) that requires adding other flags to puppeteer (--disable-web-security, --disable-site-isolation-trials).

stale[bot] commented 4 years ago

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Bruno-Tavares-Bose commented 4 years ago

Any news on this one?

stale[bot] commented 4 years ago

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

stale[bot] commented 4 years ago

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

sid-the commented 2 years ago

Is there any update on this issue or accepted workaround for this?