-
Notifications
You must be signed in to change notification settings - Fork 10
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] No coverage for file reported if JSX is used #34
Comments
For anyone stumbling upon this: Pin |
Same problem, istanbul/nyc/storybook was missing files in the coverage report. Pinning |
same issue for @storybook/react-vite 7.6.16 |
Looks like this change might be responsible. From https://storybook.js.org/docs/api/main-config-babel#babelconfig
We added |
Same issue with If my component looks like this I get coverage: export function Greeting({ name }: { name?: string }) {
if (name) {
return `Hello ${name}!`;
}
return 'Hello!';
} But if my component looks like this I get no coverage: export function DomactInfoCard({ name }: { name?: string }) {
if (name) {
return <div>Hello {name}!</div>;
}
return <div>Hello!</div>;
} |
Getting the same issue with 8.1.10. Will try downgrading Vite version to see if it has any effect. Update: Managed to solve this issue using the @vitejs/plugin-react-swc as my project was previously configured using the non swc plugin following the default config setup. All coverage is now reporting as expected 👍 |
I was actually able to fix it by upgrading everything in my project with Relevant versions:
|
Describe the bug
Coverage is not reported for files where JSX is used.
I've set up a minimal repository that recreates the issue with the same config - https://github.com/jMalojlo/sb-repro.
It's a basic button component with a story containing a play function to 'test' a click handler.
The component itself contains some JSX and imports some jsx and non-jsx module. What we see in the coverage report is that only the files without JSX are properly counted.
We're running an ejected CRA and I assume it's a Babel config issue, but can't figure this out myself.
Steps to reproduce the behavior
npm install
&&npx playwright install chrome
npm run storybook
npm run storybook-test
runs tests with--coverage
npm run generate-storybook-coverage
nyc report with lcovopen ./coverage/storybook/lcov-report/index.html
to inspect the coverage HTML fileEnvironment
The text was updated successfully, but these errors were encountered: