Skip to content

[Documentation]: Invalid TypeScript in Component Testing #31106

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

Open
magicznyleszek opened this issue Apr 14, 2025 · 0 comments
Open

[Documentation]: Invalid TypeScript in Component Testing #31106

magicznyleszek opened this issue Apr 14, 2025 · 0 comments

Comments

@magicznyleszek
Copy link

magicznyleszek commented Apr 14, 2025

Describe the problem

In https://storybook.js.org/docs/writing-tests/component-testing#assert-tests-with-vitests-apis there is a line with await waitFor(() => expect(args.onSubmit).toHaveBeenCalled());. In this line the args.onSubmit will show an error: Property 'onSubmit' does not exist on type '{}'.

It would be nice to have an official proposed solution for this. I was looking for answers around here and didn't find anything useful.

Additional context

AFAIK there is currently no way to have type safety for args in Storybook. It would be nice to acknowledge that in docs and save time for people looking for answers :)

magicznyleszek added a commit to kobotoolbox/kpi that referenced this issue Apr 14, 2025
### 💭 Notes

I was trying to come up with some "proper" way of having types in
`args`, but searching Storybook docs and thier GH gave me nothing
useful. I made an issue to kindly point this out to Storybook team:
storybookjs/storybook#31106.

Other than that, it's just a simple test to show how it's done ;)

### 👀 Preview steps

Testing:
1. ℹ️ run storybook
2. go to Design System → ActionIcon → Test Click story
3. open "Interactions" tab
4. 🟢 notice that test PASS

---------

Co-authored-by: Akuukis <Akuukis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant