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

page.addScriptTag: Refused to execute inline script #275

Closed
nicolasburtey opened this issue Mar 5, 2023 · 3 comments · Fixed by #398
Closed

page.addScriptTag: Refused to execute inline script #275

nicolasburtey opened this issue Mar 5, 2023 · 3 comments · Fixed by #398
Labels
bug Something isn't working released

Comments

@nicolasburtey
Copy link

when trying to run the test running on a react native project, I run into this issue:

 % yarn test-storybook --url http://localhost:7007 --maxWorkers=2
watchman warning:  Recrawled this watch 1 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/n/Code/react-native-template-new-architecture' ; watchman watch-project '/Users/n/Code/react-native-template-new-architecture'`

 FAIL   browser: chromium  src/components/text/text.stories.tsx
  ● Test suite failed to run

    page.addScriptTag: Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-gO06W1rzmjlE4IbFnX8Hjiu42nH+w7cA61VdAG7f8eM='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

      at setupPage (node_modules/@storybook/test-runner/dist/cjs/setup-page.js:63:14)
      at CustomEnvironment.setup (node_modules/@storybook/test-runner/playwright/custom-environment.js:9:5)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.428 s
Ran all test suites.

an easy way to reproduce this issue is to add the test runner from this repo:

https://github.com/leotm/react-native-template-new-architecture

@yannbf yannbf added the bug Something isn't working label Apr 21, 2023
@ghost-of-kla-trackunit
Copy link

Any workarounds for this issue? :)

@yannbf
Copy link
Member

yannbf commented Nov 21, 2023

Hey there! Sorry, the test-runner doesn't support React Native directly (like provided in the example template), however it does work if you use the react-native-web addon. I added a remark about that in the docs here:
https://github.com/storybookjs/test-runner#react-native-support

Copy link

🚀 Issue was released in v0.15.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants