Storybook pulls my tests
See original GitHub issueI’m attempting to migrate from the default builder to vite.
For some reason, storybook shows some error about @testing-library/dom
and pretty-format
. They should be not there in the first place because those are testing only libraries. I tried to include or exclude them from optimizeDeps
without success.
I don’t understand why it tries to pull them. Maybe it pulls all the tsconfig files, I don’t know. I have 3 tsconfig
files at the root of my project, one for dev, one for tests and one for eslint.
Edit : I talked about this issue here : https://github.com/testing-library/dom-testing-library/issues/985
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Interaction tests - Storybook - JS.ORG
How does component testing in Storybook work? ... You start by writing a story to set up the component's initial state. Then simulate...
Read more >This story has tests configured, but no file was found #13885
I have setup storybook 6.1.17 including the jest addon I have managed to get the command line jest command working and test output...
Read more >How to use Testing Library to test Storybook
You are using Storybook for your components and writing tests for them ... Storybook on GitHub, create an issue, or submit a pull...
Read more >Using Storybook stories with Testing Library - YouTube
Did you know that you can import your stories from Storybook and run them as tests ? I recently learned about this cool...
Read more >Visual Regression Testing and React Storybook
import '@storybook/addon-knobs/register';. Next, you can add the Knobs to all your stories globally (you could do it for each story individually ...
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 Free
Top 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
Ok I finally got it working. I was all wrong. Oh boy. I was wrong.
Turns out my main
tsconfig.json
is used, by default. I still use the plugin so it includes theroot
for my aliases but that’s all it will do for me. The problem is that in my verytsconfig.json
I’m only exluding the usuals :Turns out to build my stories I use some utils I created. Those utils were located in a file along with other utils. Those other utils were using and therefore importing
@testing-library/react
. So I split all my utils into three files :dev-common-utils.tsx
for shared utils,stories-utils.tsx
for stories-only utils, and finallytests-utils.tsx
forjest
stuff, including@testing-library
. Now, onlytests-utils.tsx
imports@testing-library
. I also notice mysetupTests.ts
was included in mytsconfig.json
and also carries some imports of@testing-library
.So after splitting my utils I updated my
tsconfig.json
to the following :My
.storybook/main.js viteFinal
looks very casual now :I hope I gave enough details so people struggling with the same issue can fix it more quickly than I did 😃
Right now what seems the closest to work is :