-
Notifications
You must be signed in to change notification settings - Fork 77
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
Extend hooks api with prepare
and getHttpHeaders
properties
#245
Conversation
acc88f0
to
89d8b97
Compare
@davidferguson the |
Thanks @yannbf, this exactly fits our needs! Looking forward to being able to use this once it's merged. |
@yannbf merge it?! |
Bump, would love to see this merged at some point! |
Just wanted to give this another bump! |
Hey @davidferguson sorry for the long time to merge this, got quite busy with the Storybook day conference! |
🚀 PR was released in |
Replaces #222
There are now additional properties you can set in
.storybook/test-runner.js
:prepare
The test-runner has a default
prepare
function which gets the browser in the right environment before testing the stories. You can override this behavior, in case you might want to hack the behavior of the browser. For example, you might want to set a cookie, or add query parameters to the visiting URL, or do some authentication before reaching the Storybook URL. You can do that by overriding theprepare
function.The
prepare
function receives an object containing:browserContext
: a Playwright Browser Context instancepage
: a Playwright Page instance.testRunnerConfig
: the test runner configuration object, coming from the.storybook/test-runner.js
.getHttpHeaders
The test-runner makes a few
fetch
calls to check the status of a Storybook instance, and to get the index of the Storybook's stories. Additionally, it visits a page using Playwright. In all of these scenarios, it's possible, depending on where your Storybook is hosted, that you might need to set some HTTP headers. For example, if your Storybook is hosted behind a basic authentication, you might need to set theAuthorization
header. You can do so by passing agetHttpHeaders
function to your test-runner config. That function receives theurl
of the fetch calls and page visits, and should return an object with the headers to be set.📦 Published PR as canary version:
0.9.5--canary.245.714d3ca.0
✨ Test out this PR locally via:
npm install @storybook/test-runner@0.9.5--canary.245.714d3ca.0 # or yarn add @storybook/test-runner@0.9.5--canary.245.714d3ca.0
Version
Published prerelease version:
v0.10.0-next.10
Changelog
🚀 Enhancement
🐛 Bug Fix
prepare
andgetHttpHeaders
properties #245 (@yannbf)📝 Documentation
Authors: 8