addon-coverage icon indicating copy to clipboard operation
addon-coverage copied to clipboard

[Vite -> React -> Typescript + SWC] Empty (no, 0, files found) code coverage report

Open sebaguozden opened this issue 1 year ago • 4 comments

Describe the bug

Everything runs smoothly with pnpm test-storybook. On the other hand, pnpm test-storybook --coverage returns an empty coverage report.

Steps to reproduce the behavior

  1. Run pnpm storybook
  2. Run pnpm test-storybook --coverage
  3. Console Coverage Summary will be empty (no files found)
  4. coverage/storybook/coverage-storybook.json only contains {}

Expected behavior

Show **/*.tsx files on the report.

Screenshots and/or logs

.storybook/main.ts image

package.json image

EMPTY Coverage (Console) Report image

EMPTY Coverage (File) Report image

Environment

  • OS: Ubuntu 22.04.2 (WSL)
  • Node.js version: v20.9.0
  • PNPM version: 8.10.2 -> Also happens with NPM version: 10.1.0
  • Browser (if applicable): chrome
  • Browser version (if applicable): Not Sure (installed through playwright pnpm exec playwright install + pnpm exec playwright install-deps)
  • Device (if applicable): Not Applicable

sebaguozden avatar Nov 03 '23 15:11 sebaguozden

It is related to https://github.com/storybookjs/addon-coverage/issues/17. Addon is not compatible with @vitejs/plugin-react-swc. Any idea how to fix it?

sebaguozden avatar Nov 06 '23 14:11 sebaguozden

I have the exact same issue but I am not using @vitejs/plugin-react-swc, I have @vitejs/plugin-react in my package.json

DawidWraga avatar Dec 26 '23 17:12 DawidWraga

Checking the coverage-storybook.json output, I find that the missing components are in my output json file but the file path is wrong. Instead of /path/to/my/Component.tsx, they are /path/to/my/Component. I guess that's why the nyc report cannot find them in my cases

zeroliu avatar Mar 26 '24 22:03 zeroliu

I have the exact issue. I am using addon-coverage with @storybook/addon-webpack5-compiler-swc. My project doesn't work with babel-loader so i removed it from webpack config and custom configured to use swc-loader instead. and it returns 0 coverage on files

Ravina1604 avatar Apr 22 '24 22:04 Ravina1604