Skip to content
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] Coverage Report is Empty #313

Closed
jeffcap1 opened this issue Jun 14, 2023 · 2 comments · Fixed by #324
Closed

[Bug] Coverage Report is Empty #313

jeffcap1 opened this issue Jun 14, 2023 · 2 comments · Fixed by #324

Comments

@jeffcap1
Copy link

jeffcap1 commented Jun 14, 2023

Describe the bug
Coverage report does not seem to be working in Storybook 7 with Vite. The test runner will go through and test the stories as expected, but no information is displayed in the coverage table or underlying coverage json file. I tried this on both a brand new Vite project as well as an existing Vite project I was upgrading to Storybook 7 and experienced the same issue.

To Reproduce
Steps to reproduce the behavior:

  1. npm create vite@latest {PROJECT_NAME} -- --template react
  2. cd {PROJECT_NAME} && npm install
  3. npx storybook@latest init
  4. npm install -D @storybook/test-runner @storybook/addon-coverage
  5. Add "@storybook/addon-coverage" to the .storybook/main.js addons array
  6. run the command npm run storybook
  7. in a new terminal run npx test-storybook --coverage
  8. the stories will be tested, but the output of the coverage will be an empty table.

Expected behavior
The coverage table would show the tested components from the stories as well as the number of covered lines. The coverage/storybook/coverage-storybook.json should also be populated with information.

Screenshots
image

image

System
Environment Info:

System:
OS: macOS 13.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v16.19.1/bin/npm
Browsers:
Safari: 16.5
npmPackages:
@storybook/addon-coverage: ^0.0.8 => 0.0.8
@storybook/addon-essentials: ^7.0.20 => 7.0.20
@storybook/addon-interactions: ^7.0.20 => 7.0.20
@storybook/addon-links: ^7.0.20 => 7.0.20
@storybook/blocks: ^7.0.20 => 7.0.20
@storybook/react: ^7.0.20 => 7.0.20
@storybook/react-vite: ^7.0.20 => 7.0.20
@storybook/test-runner: ^0.10.0 => 0.10.0
@storybook/testing-library: ^0.0.14-next.2 => 0.0.14-next.2

@jeffcap1 jeffcap1 changed the title [bug] Coverage Report is Empty [bug] Jun 14, 2023
@jeffcap1 jeffcap1 changed the title Coverage Report is Empty [bug] [Bug] Coverage Report is Empty Jun 14, 2023
@cezudas
Copy link

cezudas commented Jun 25, 2023

First of all, I am very grateful to have Storybook as OSS and have been using it happily for a couple of years now.

@jeffcap1 I really wish I could help as I myself just spent more than a couple of hours to get to the bottom of this.

I used Storybook CLI to update to the latest (from v7.0.5 to v7.0.23).
I got the same problem with the test-storybook not honoring the --coverage option anymore.

In my case running pnpm dlx storybook@latest upgrade also bumped [@storybook/test-runner]
Screenshot 2023-06-25 at 16 36 43

(https://npmjs.com/package/@storybook/test-runner) from v0.10.0 to v0.11.0. Going back to v0.10.0 fixed the problem for me. See below my final package.json diff, I am happy to say the coverage report is created.
Screenshot 2023-06-25 at 16 25 48

@jeffcap1
Copy link
Author

I just tried the same approach as @cezudas by running npx storybook@latest upgrade on the brand new vite project to get to version 7.0.24. I then ran npx test-storybook --coverage with @storybook/test-runner at 0.11.0 and rolling then back to 0.10.0. Unfortunately, neither seemed to produce a working coverage report. What I did notice is on 0.10.0 I get an empty table output to the terminal, however, 0.11.0 I do not see a table. In both scenarios the coverage report json is empty.

bryanjtc added a commit that referenced this issue Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants