Inherit preview.js parameters handlers in stories
See original GitHub issueAs per Storybook rules of parameter inheritance, using msw in stories should inherit/concat the handlers from the preview.js parameters.
Example: The API I am using requires that I make a call for an oauth token before I can call any API call. In the current way this addon works, I have to duplicate this resolver in every single story that defines msw in its parameters because it overwrites the one from preview.js instead of merging with it.
preview.js
export const parameters = {
actions: {argTypesRegex: '^on[A-Z].*'},
msw: [
rest.post('/oauth/token', (req, res, ctx) =>
res(ctx.json({token_type: 'Bearer', access_token: 'test_token'}))
),
],
};
thing.stories.js
export default {
component: Thing,
parameters: {
msw: [
rest.get('/some/endpoint', (req, res, ctx) =>
res(ctx.json([]))
),
],
},
};
Both handlers should work in the story. Currently, the oauth/token handler is not included in the story.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Parameters - Storybook
Parameters are a set of static, named metadata about a story, typically used to control the behavior of Storybook features and addons.
Read more >Configuring Storybook: 6 Tips You Can't Miss | by Zheng Li
To control the way stories are rendered and add global decorators and parameters, create a .storybook/preview.js file. This is loaded in the ...
Read more >Safari Technology Preview Release Notes - Apple Developer
Release 156 · Web Inspector · CSS · JavaScript · Rendering · Media · Web Animations · Accessibility · Web API.
Read more >Layouts and Rendering in Rails - Ruby on Rails Guides
Rails will automatically render app/views/books/index.html.erb when you ... is done by nested classes of the module ActionView::Template::Handlers .
Read more >Visualizing Data and Building Reports in Oracle Analytics Cloud
This topic covers how you capture insights and group them into stories. ... You can use preview mode to view and interact with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sklawren this is an interesting pattern. i wasn’t a fan initially because “object merge with array flattening” is harder to explain than “object merge”, but if one really wants to use arrays, this gets that AND merge AND backwards compatibility, which is pretty cool. A+ for creativity. my vote would still be for the simplicity of object merge, but i’ve got no horse in this race! 🏇
@kettanaito If you accumulate arrays then there’s no natural way to override anything that’s defined in a higher level in the hierarchy. The decision was made five years ago, so it’s all a distant memory at this point. But my recollection is that initially we merged arrays and then we backed it out based on problems it caused.