Skip to content
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

Nyc + ava gives 0 on all coverage lines #2417

Closed
ghost opened this issue Mar 6, 2020 · 3 comments
Closed

Nyc + ava gives 0 on all coverage lines #2417

ghost opened this issue Mar 6, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 6, 2020

I followed the steps from https://github.com/avajs/ava/blob/master/docs/recipes/code-coverage.md

My ava config from package.json is

"scripts": {
    "test": "ava",
    "coverage": "nyc ava"
},
"ava": {
    "files": [
      "src/test/**/*.spec.js"
    ],
    "require": [
      "./src/test/_setup-browser-env.js"
    ],
    "verbose": true
  }

When I run the coverage script I get this:

image

I don't use babel, and imports are done with import not require.
I'm on the latest versions of node.js, ava, nyc

@ghost ghost added the needs triage label Mar 6, 2020
@novemberborn
Copy link
Member

I sometimes have trouble getting good reports out of nyc ava as well. Sometimes it helps to delete the coverage and .nyc_output directories. Maybe even node_modules/.cache.

I don't use babel, and imports are done with import not require.

So… you're using ESM with Node.js 13? There's a good chance that nyc cannot deal with that yet.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@ghost
Copy link
Author

ghost commented Mar 8, 2020

For some people nyc and esm works istanbuljs/nyc#905
I opened a ticket on nyc istanbuljs/nyc#1287 since it's more related to that than ava.
Thanks.

@DemianD
Copy link

DemianD commented Apr 12, 2020

Instead of using nyc, you can use https://github.com/bcoe/c8 which works with esm

npm install --save c8
"scripts": {
  "test": "ava",
  "coverage": "c8 --reporter=html --reporter=text ava"
}

matatk added a commit to matatk/landmarks that referenced this issue Jul 28, 2020
This avoids the need for the generated CJS files and use of rollup in testing.

Thanks to https://remysharp.com/2019/08/16/build-free-code-and-testing-es-module-imports
and avajs/ava#2417 (comment) :-).
matatk added a commit to matatk/landmarks that referenced this issue Jul 28, 2020
This avoids the need for the generated CJS files and use of rollup in testing.

Thanks to https://remysharp.com/2019/08/16/build-free-code-and-testing-es-module-imports and avajs/ava#2417 (comment) :-).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants