[ViteJS] Empty coverage for all files not covered by tests
See original GitHub issueVersions
- What is this plugin’s version? 3.9.12
- What is Cypress version? 9.1.0
- What is your operating system? MacOS
- How do you instrument your application? Instanbul
- Is there
.nyc_output
folder? Yes, not empty - Do you have any custom NYC settings? Yes,
all
- Do you run Cypress tests in a Docker container? No
Describe the bug
Despite using the all
setting of NYC, it seems like only files touched by tests have their line numbers included in the report.
The other files are present but show 0 lines thus are ignored in the final computation of the code coverage.
Using the debug flag, I see them added:
code-coverage adding empty coverage for file /Users/Sytten/Projects/*****/src/main.ts +0ms
code-coverage adding empty coverage for file /Users/Sytten/Projects/*****/src/composables/index.ts +0ms
code-coverage adding empty coverage for file /Users/Sytten/Projects/*****/src/composables/useId.ts +0ms
code-coverage adding empty coverage for file /Users/Sytten/Projects/*****src/composables/useName.ts +0ms
But I would expect them to get line numbers at some point. But they only get:
TN:
SF:src/main.ts
FNF:0
FNH:0
LF:0
LH:0
BRF:0
BRH:0
end_of_record
I use ViteJS and my plugins looks like:
const path = require("path");
const { startDevServer } = require("@cypress/vite-dev-server");
const codeCoverageTask = require("@cypress/code-coverage/task");
const istanbul = require("vite-plugin-istanbul");
module.exports = (on, config) => {
on("dev-server:start", (options) =>
startDevServer({
options,
viteConfig: {
logLevel: "warn",
configFile: path.resolve(__dirname, "..", "..", "vite.config.js"),
plugins: [istanbul({})],
},
})
);
codeCoverageTask(on, config);
return config;
};
Support contains:
// Import commands.js using ES2015 syntax:
import "./commands";
// Alternatively you can use CommonJS syntax:
// require('./commands')
import "@cypress/code-coverage/support";
The coverage for files under test works fine.
Link to the repo This is not an open-source project, but happy to provide a reproduction if that can help debug it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (6 by maintainers)
Top Results From Across the Web
vitest test coverage does not fail when threshold is not met
You are running tests in watch mode (Waiting for file changes...) Use this command to run without watch mode: vitest run.
Read more >Configuring Vite
Configuring Vite #. When running vite from the command line, Vite will automatically try to resolve a config file named vite.config.js inside project...
Read more >Migrating from Jest to Vitest - Tech with Cathal
I recently migrated from create-react-app (CRA) to ViteJS, ... entry to run code coverage and provided a way to run tests without a...
Read more >Testing Vite with minimal config using Vitest - LogRocket Blog
Well, instead of targeting a single main.js file as our website's entry point, it crawls HTML files to track all JavaScript, styles, ...
Read more >No coverage for .vue files when using Jest - Get Help
I'm using vue-test-utils with Jest to test single-file Vue components. Everything seems to be working fine, but I'm unable to generate ...
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 FreeTop 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
Top GitHub Comments
Thanks for the bug report - this should be enough to reproduce and work on this issue.
I am looking into code coverage for Vite.