-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Bug]: All fn()
stubs get logged in the Actions
panel, not just the component's args
#27534
Comments
@kasperpeulen is there any way to disable logging of spies if it's not desired? |
@jalooc We do want to (allow people to) show spies in the action panel: We use it extensively in our RSC demo. It show mocks that we automatically set for the nextjs framework (cookies/redirect etc.) And it also shows the spies that are manually attached to the (in memory) database. https://github.com/storybookjs/storybook-rsc-demo But I do agree with you, it very fast become way too noisy. Actually we hardcoded to not show all spies in the action panel that the nextjs framework adds by default: storybook/code/addons/actions/src/loaders.ts Lines 20 to 43 in 174bd22
Which is certainly not ideal, but we didn't have time to make a dedicated action filtering solution yet. For the short term I propose that we only log spies if they have a name. You can set a name with For a long term solution, I think it would be best to have 2 mock types:
The API might be: We could automatically enhance all event handlers (onClick etc) to be There still might be cases where you do want to add a name to the spy, and it really is an action, but you still don't want to show it in the action panel by default. For those cases, I think we could have some parameter convention: parameters: {
actions: {
filter: {
'API.getAll': false,
'next/headers::cookies().get': false,
`^next/router::useRouter\\(\\)`: true // maybe even regex?
}
}, Where every addon can disable showing some spies. E.g. this is what the next addon would use. To only show the useful stuff in the action panel. And then users can:
|
@kasperpeulen I like your "no name" solution as a short term fix. Let's do it. For the larger fix, please write a short RFC and let's discuss as a small batch project. |
Sorry for the late reply. Answering that comment: Yes, logging spies if they have a name sounds like a reasonable short-term fix. As for the long-terms solution - not sure about adding the division between query and action, cause it kind of enofrces a quite opinionated view on how a dev should treat the actions, whereas I really liked the freedom of the old On that note - wouldn't it be possible to bring back that |
Describe the bug
Not only the
fn()
arg types are logged in theActions
tab, but all thefn()
s used anywhere.A sample case I've been tackling with, after upgrading SB to v8, is that I've got quite a lot of stubs defined using
fn()
for mocked api modules in my application (using the__mock__
folder method withstorybook-addon-manual-mocks
). All their invocations get logged in theActions
panel when the component story is invoked, but it does not make sense to have them logged in there - they're neither actions, nor anything relevant to the person using the story. In some cases, when a more complex component, like a page component, makes lots of those mocked api requests, this behaviour renders theActions
tab completely unusable, littering it with irrelevant entries.First mention: #24392 (comment)
Reproduction link
https://stackblitz.com/edit/github-xdgoog?file=src%2Fstories%2F__mocks__%2Fapi.ts
Reproduction steps
Page
story.Actions
tab.fn()
stub from the__mocks__
directory being logged.System
Additional context
No response
The text was updated successfully, but these errors were encountered: