Closed jnahumphreys closed 5 months ago
Installing nyc
as a dev dependency fixed it for me.
I'm experiencing the same issue on Windows.
18.13.0
8.19.3
I tried installing nyc
as a dev dependency, but that didn't work either.
Just a heads-up that I encountered this error and determined the cause to be a space in the directory name.
In this case:
/Users/james/Development/Personal Projects/
I had a similar situation (storing files in Google Drive which uses /My Drive/
). Moving the project to a directory without spaces resolved the issue.
My guess is that nyc
isn't properly quoting the directory that's supplied to it as an argument.
Same issue here, tried to add nyc as dev dependency but that doesn't bring anything. No spaces in my directories.
Plus 1 on this issue. StoryBook runs with no errors, and tests pass with no errors. It looks like code coverage is created successfully (in .nyc_output/coverage.json
) and if i run nyc report
i see the coverage in the terminal as expected. it just doesn't show up after running npm run test-storybook --coverage
.
"storybook:test": "test-storybook --coverage --coverageDirectory .storybook && nyc report --reporter=text -t coverage/storybook --report-dir .storybook",
I followed this: https://storybook.js.org/tutorials/ui-testing-handbook/react/en/introduction/
and attempted to add the coverage addon according to this: https://storybook.js.org/docs/writing-tests/test-coverage#code-instrumentation-with-the-coverage-addon
And I do not see a coverage report in the terminal when invoking npm run test-storybook --coverage
. Nor do I see an nyc output file generated at .nyc_output/coverage.json
Changing the test script to match the suggestion from @MisterCommit does output a report in the terminal - but it is missing many of the files that should have been exercised.
All tests run and pass.
repo here: https://github.com/Visible-Radio/ui-testing-guide-code
Also, experience this issue. Added a quick nextjs repo where you can see that there is no coverage report in the console running pnpm run test-storybook --coverage
But it producing coverage/storybook/coverage-storybook.json
which can be placed into .nyc_output
folder to be able to get the report running nyc report
command
Also seeing this problem as well some additional issues:
.nycrc
file with some percentage config
{
"all": true,
"check-coverage": true,
"branches": 80,
"functions": 80,
"lines": 80,
"statements": 80
}
.nycrc.json
with extensions set to .vue
and .ts
"devDependencies": {
"@azure/static-web-apps-cli": "^1.1.7",
"@storybook/addon-coverage": "^1.0.1",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-interactions": "^8.0.4",
"@storybook/addon-links": "^8.0.4",
"@storybook/blocks": "^8.0.4",
"@storybook/test": "^8.0.4",
"@storybook/test-runner": "^0.17.0",
"@storybook/vue3": "^8.0.4",
"@storybook/vue3-vite": "^8.0.4",
"@types/jest": "^29.5.12",
"@types/jest-image-snapshot": "^6.4.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vitejs/plugin-vue": "^5.0.4",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-vue": "^9.24.0",
"http-server": "^14.1.1",
"istanbul": "^0.4.5",
"jest-image-snapshot": "^6.4.0",
"nhsuk-frontend": "^8.1.1",
"sass": "^1.72.0",
"storybook": "^8.0.4",
"storybook-vue3-router": "^5.0.0",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vue-tsc": "^2.0.6",
"wait-on": "^7.2.0"
}
I followed the Storbook docs https://storybook.js.org/docs/writing-tests/test-coverage and am currently generating a single json file. Coverage file (5797 bytes) written to .nyc_output/coverage.json
in the terminal.
I have tried many commands and solutions posted from various sites etc. For example, the command posted above test-storybook --coverage --coverageDirectory .storybook && nyc report --reporter=text -t coverage/storybook --report-dir .storybook
, simply doesn't work for me.
The only progress I have made was to manually install istanbul
and run a command to convert the JSON file into an HTML report. This is when I noticed only 2 of my components/stories were being scanned.
Any ideas would be much appreciated
Hey everyone! Sorry about this, there is a regression in the Storybook test-runner which causes the report not to be shown. The issue will be fixed in upcoming versions!
Hey everyone, the issue is now fixed in 0.18.0, closed by #456. Thanks!
@edwardscull I appreciate the detail you put in your comment!
- I wold like to generate HTML reports and not just a single JSON file
- I would like to see the terminal printout showing the results
These are default in 0.18.0
I would like to see all my components in the coverage results. Currently I am only seeing 2 of my components
You might need to use the istanbul options in the addon coverage to include different directories: https://github.com/storybookjs/addon-coverage#configuring-the-addon
Describe the bug
On running
npm test-storybook --coverage
the coverage report is failing to print to the console (tests run fine btw)Steps to reproduce the behavior
npm run storybook
npm run storybook --coverage
Expected behavior
My tests should run and print the coverage report to my console once all tests are comple
Screenshots and/or logs
Environment
Additional context
My Typescript has been instrumented successfully, after running
npm run storybook --coverage
I can generate an lcov report by runningnpx nyc report --reporter=lcov -t coverage/storybook --report-dir coverage/storybook
.