This repository was archived by the owner on Nov 19, 2026. It is now read-only.
Repository navigation
Extend hooks api with prepare and getHttpHeaders properties - #245
Merged
Merged
Conversation
yannbf
force-pushed
the
feat/provide-prepare-api-and-browser-context
branch
from
January 20, 2023 14:49
acc88f0 to
89d8b97
Compare
Member
Author
|
@davidferguson the |
|
Thanks @yannbf, this exactly fits our needs! Looking forward to being able to use this once it's merged. |
ndelangen
approved these changes
Jan 24, 2023
Member
|
@yannbf merge it?! |
|
Bump, would love to see this merged at some point! |
|
Just wanted to give this another bump! |
Member
Author
|
Hey @davidferguson sorry for the long time to merge this, got quite busy with the Storybook day conference! |
This was referenced Mar 31, 2023
Merged
Merged
|
🚀 PR was released in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #222
There are now additional properties you can set in
.storybook/test-runner.js:prepare
The test-runner has a default
preparefunction 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 thepreparefunction.The
preparefunction 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
fetchcalls 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 theAuthorizationheader. You can do so by passing agetHttpHeadersfunction to your test-runner config. That function receives theurlof 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.0Version
Published prerelease version:
v0.10.0-next.10Changelog
🚀 Enhancement
🐛 Bug Fix
prepareandgetHttpHeadersproperties #245 (@yannbf)📝 Documentation
Authors: 8