-
-
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
Test: Create @storybook/test package based on vitest #24392
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
29f8596
Create @storybook/test package
kasperpeulen f0d68a1
Replace expect (from jest) with @vitest/expect
kasperpeulen 97350aa
Fix build
kasperpeulen daeffb5
Move testing library to test package + some improvements
kasperpeulen 1f02904
Add testing library assertion on expect
kasperpeulen b406b6d
Make sure synchronous methods are always promises, even in the first run
kasperpeulen 76c109a
Revert mistake
kasperpeulen d034a44
Clear spies and instrument spies by event handler name
kasperpeulen e6b0f0a
Show deprecation message
kasperpeulen 9d88027
Revert making get* method's promises and make sure we instrument `not`
kasperpeulen ea2c3c3
fix yarn lock
yannbf 33cbcae
Fix eslint
kasperpeulen 6d19861
Comment out deprecation for now
kasperpeulen 0b76716
Fix types
kasperpeulen da91e3d
Make getters lazy and fix workspace
kasperpeulen 17b3a33
Fix yarn.lock
kasperpeulen fae8299
Fix type fest range
kasperpeulen 2085dd4
Patch vitest to make it compatible with the jest runner
kasperpeulen 39ed28d
Add jest types to lock
kasperpeulen ddd8bf1
Better patch
kasperpeulen 27ded25
Fix lock
kasperpeulen d44e0bd
Fix lazy getters
kasperpeulen 8657c59
Fix gitignore
kasperpeulen db9bb66
Merge branch 'next' into kasper/test-package
kasperpeulen a5cdd31
Fix getter
kasperpeulen d62d5b2
Merge remote-tracking branch 'origin/next' into kasper/test-package
kasperpeulen de86f5d
Always externalize @vitest deps in tsup, as they are ESM-only. But st…
kasperpeulen 6ee27f2
Always install extra deps
kasperpeulen 47586d9
Fix getters that use `this`
kasperpeulen 4ae6a77
Fix deps issue
kasperpeulen 5497868
Merge remote-tracking branch 'origin/next' into kasper/bladiebla
kasperpeulen 6de0d49
Fix lock files
kasperpeulen 2b9981a
Fix check script
kasperpeulen fb84613
Calculate the diff for chai errors
kasperpeulen 6801e04
Add moduleNameMapper for ESM only modules with package json exports
kasperpeulen ef847b9
Downcast function types that are mocks in meta args
kasperpeulen d843514
Merge branch 'next' into kapser/test-package2
ndelangen f42e9ef
Pre bundle most deps of the test package
kasperpeulen 43ee7d5
Merge remote-tracking branch 'origin/next' into kapser/test-package2
kasperpeulen a8edebd
Merge branch 'next' into kapser/test-package2
kasperpeulen bcf87ea
Fix eslint
kasperpeulen 19f2409
Merge branch 'next' into kapser/test-package2
kasperpeulen d888f60
Fix next version
kasperpeulen 4f08e77
Merge remote-tracking branch 'origin/kapser/test-package2' into kapse…
kasperpeulen 4e993be
Merge remote-tracking branch 'origin/next' into kapser/test-package2
kasperpeulen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
code/.yarn/patches/@vitest-expect-npm-0.34.5-8031508efe.patch
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ArgsEnhancer } from '@storybook/types'; | ||
import { addActionsFromArgTypes, inferActionsFromArgTypesRegex } from './addArgsHelpers'; | ||
import { | ||
addActionsFromArgTypes, | ||
attachActionsToFunctionMocks, | ||
inferActionsFromArgTypesRegex, | ||
} from './addArgsHelpers'; | ||
|
||
export const argsEnhancers: ArgsEnhancer[] = [ | ||
addActionsFromArgTypes, | ||
inferActionsFromArgTypesRegex, | ||
attachActionsToFunctionMocks, | ||
]; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, nice job with the PR, useful stuff. One problem I found (not sure if this code is the cause, but it's the closest that I was able to find) is that now not only the
fn()
arg types are logged in theActions
tab, but all thefn()
s defined anywhere. Not sure if this is expected or a bug, but looking at the code here, that's not how it was meant to work 🧐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). 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 no 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.Does that behaviour sound familiar? Anything that can be bypassed / fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make an issue for this? I have some plans to bypass this behavior, but nothing concrete yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the easiest thing we can do as a starter, is only log it if the mockName is set:
https://vitest.dev/api/mock.html#mockname
As otherwise it will only log
spy
and nothing something useful anyway.I'm also thinking about enriching the
fn
with a type.fn().type('action')
fn().type('query')
And only show the type
action
by default. And hide all other types (or those without type), but still be able to show them by changing the action filter or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is: #27534
Wasn't sure what type of issue that should be; went with bug since seems to me that both the documentation and the code indicate that only the
fn()
s used inargs
should be logged in theActions
tab.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answering your suggestions @kasperpeulen - could you point out how/where it happens that all
fn()
s get intercepted and logged in the tab? Looking at the code here, I'd say it's clear that only the ones defined inargs
should be enhanced 🧐That knowledge would help me provide better feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I added a link to the code in the response of your issue!