https://cypress.io logo
Cypress code coverage
# i-need-help
a
Hello guys, I'm having this error with my Cypress code Coverage, I'm using Vue.js3 +VueCLI This is the error : "log⚠️ Code coverage tasks were not registered by the plugins file. See support issue for possible workarounds. [@cypress/code-coverage]" Can anyone help me pls ?
this is my package.json :
e
Are you defining
require('@cypress/code-coverage/task')(on, config)
in both the
cypress.config.js
and
plugins/index.js
file? I'm not sure if that could cause problems or not but it's unneeded.
a
thanks for answering man I will try that tomorrow and let you know if that worked
okay it works man @enough-truck-68085
thanks a lot
I was wondering if you had any idea on how to do some code coverage on my whole application ?
e
That's a pretty generic ask...is there anything else in particular you are having trouble with though? Or can you elaborate on your question above?
a
I don't understand why it doesn't take my components and my views
Hey @enough-truck-68085 I hope you are doing well ! I'm still stuck on my problem but I don't understand why now I have nothing inside my code coverage
Now when I do that command I receive this : npx nyc report --reporter lcov --reporter text-summary =============================== Coverage summary =============================== Statements : Unknown% ( 0/0 ) Branches : Unknown% ( 0/0 ) Functions : Unknown% ( 0/0 ) Lines : Unknown% ( 0/0 ) ================================================================================
like this is my Icov-report but I don't see my files (src and component for example)
I apologize
I have no idea how I did it but i did it
e
@acceptable-angle-31500 , sorry been busy the past few days. I'm looking now but it seems like you've got some good outputs? Any idea what changed?
a
those pictures are what I did
chat GPT helped me a lot to be honest
e
e2e.js
is what the difference is. You needed that import
a
no problem btw thanks for answering no one else tried to help me so i'm very grateful
yep yep so happy it finally works
e
I'm glad you got it resolved and sorry for the late reply again. Congrats on the outcome! That's a really cool feeling to see code coverage and some quantitative results from your tests!
a
thanks a lot man !
can we keep this questions open in case I have more question ?
e
Of course or feel free to message me separately about anything else. I hope you have a good weekend
a
thanks again
k
I could maybe use your help! I have a very similar setup, except I'm using react instead of vue. I see results. but for some reason my coverage report is empty. Do you mind telling me how you run your test command, i.e. what it looks like in package.json/scripts ? I was never sure if this is right;
npx nyc cypress run --component
Copy code
Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  Timer.cy.tsx                             00:02        4        4        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:02        4        4        -        -        -  

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------
i couldn't find any examples where the test suite invocation included nyc so I'm confused. Thats the only way I can get any kind of coverage output (all zeros like you see above). But it seemed like the istanbul plugin was supposed to do that automatically.
I copied a lot of the config you pasted above (replacing react for vue), thanks for posting! it helps confirm some of what I"m doing. Unfortunately same result though
Copy code
=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================
a
sorry man didn't saw your message
"cypress:open": "cypress open", "cypress:run": "cypress run --env coverage=true",
those are in my package.json
k
No worries at all, thanks for following up! For me it ended up working as I thought it should, i invoke nyc and pass the cypress run commands to it. Since cypress is my primary test suite for the moment, its simple for now: "test": "npx nyc cypress run --component --reporter junit"
m
hey, have you ace this issue: ERROR: Coverage for lines (0%) does not meet global threshold (90%)

https://cdn.discordapp.com/attachments/1084478813787922473/1100850373910077571/image.png