cypress-io / code-coverage

Saves the code coverage collected during Cypress tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Full vite support

bmulholland opened this issue · comments

I'm upgrading to Vue 3 via Nuxt 3, which pretty much forces me into Vite. (I wish it weren't so.)

I'd like to maintain code coverage. I think this package is the only way to get cypress code coverage, right? It's used e.g. here https://github.com/nefayran/cypress-react-vite/blob/main/package.json

But this package also depends on a webpack preprocessor, and has peer dependencies of webpack and babel-loader, both of which aren't used for vite. I'm not using those, and would prefer not to be installing them. I also would prefer to avoid confusion, with my package.json having both webpack and vite.

I can say, from experience, that you do not need to install Webpack in your project to use this plugin. We recently migrated away from it and do not have it directly installed in the project. However, the @cypress/code-coverage library does have Webpack as a dev dependency, so you will have it present in that case. (It just won't be visible as a direct dependency of the project.)

In the case of Babel, I'm working through that now myself, but my current understanding is that I have to install any plugins Babel may need to transform the code. That means in my case I need @babel/preset-react and babel-plugin-istanbul, but don't need to install @babel/core and @babel/preset-env. Those last two are dev dependencies of the code coverage library.

I would like to step away completely from needing Babel, and I am looking at that, but that's a much bigger task, it seems.

Yep, not actually required to install, but yarn does output:

➤ YN0000: ┌ Post-resolution validation
➤ YN0002: │ workspace:. doesn't provide babel-loader (p7a636), requested by @cypress/code-coverage.
➤ YN0002: │ workspace:. doesn't provide webpack (p224d8), requested by @cypress/code-coverage.

That's not accurate; they're not actually peer deps.