-
Notifications
You must be signed in to change notification settings - Fork 108
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
component testing suport #596
Comments
+1 on this, anyone able to comment around supporting coverage for component tests? |
It seems to work if you follow the e2e coverage guide and just substitute |
@SystemParadox , Did you manage to collect coverage for Angular Cypress component tests? If so, could you share your repo? |
We use svelte not angular, but once you've got component tests working, following the e2e coverage guide should work, just substitute |
@ShellyDCMS It's been a pain but managed to configure code coverage for cypress component tests. |
@bindea-mihai thx alot for this, it works with lib also |
@bindea-mihai , you rock!!! Thanks, man. |
@bindea-mihai @ShellyDCMS Now we only need coverage for cypress e2e tests and we are golden |
@jerkovicl this is a very good tutorial to add coverage to e2e tests |
@bindea-mihai yeah i found that aswell and didnt work for me, Istanbul loader plugin didn't instrument code sadly |
@jerkovicl , the e2e tutorial didn't work for me as well at first, but then I took a look at the example repo (which has minor differences) and it worked. |
@ShellyDCMS thx for the tip, managed to set it up in the end |
It seems cypress/code-coverage/task just can support e2e testing even I tried @bindea-mihai mentioned solution, any ideas? thanks
I know that cypress plugin will use .nyc_output/out.json file to generate code coverage report, I tried below code for component testing but the file .nyc_output/out.json will not be updated (just includes e2e related file coverage info) so code coverage report can't be generated correclty.
For e2e it works what means after I finished e2e testing the file .nyc_output/out.json will be updated and code coverage report can be generated correctly.
BTW, I can't see begin and end collect code coverage info in cypress GUI for component testing, but I can see it in e2e testing, another thing is that I can see all instrument file information in window.coverage in the F12 "Application under test iframe" when do component testing what includes component testing imported react component file, but don't know why it doesn't work as office said at https://www.npmjs.com/package/@cypress/code-coverage
|
I'm using Vite and have got the code instrumenting happening in the component tests ( Edit: ah, the reason it wasn't working was because I missed the need for // cypress/component/support/component.js
import '@cypress/code-coverage/support' |
Hi, I have the coverage "partialy working". I use Vite and and this plugin to instrument my code : https://www.npmjs.com/package/vite-plugin-istanbul I have a single test with one mount but my report tells me that my component runs twice :/. Anyone with the same issue ? |
Thank you! I was also missing this. |
Did anyone experience problem instrumenting code for component testing based on webpack? It works for E2E testing and code is properly instrumented as coverage is available on window, while for component testing it is not. I am using @quasar/quasar-app-extension-testing-e2e-cypress/cct-dev-server for my dev server which basically mimics webpack config that is used for build and development where coverage available. Any thoughts appreciated |
Not able to generate proper coverage info for cypress component tests. It says "Could not find any coverage information in your application by looking at the window coverage object. Did you forget to instrument your application?" Thanks in advance. |
@shrinidhimayya |
@ShellyDCMS looking for component tests example using svelte |
the Lit example uses svelte cypress configuration, maybe it can be of use to you. |
@ShellyDCMS , Thanks for sharing example. I am still getting error when I run component tests : "Could not find any coverage information in your application by looking at the window coverage object. Did you forget to instrument your application?" These are my set up : package.json: "nyc": { cypress.config.js module.exports = defineConfig({ webpack.config.js const { WebpackPluginIstanbul } = require("webpack-plugin-istanbul"); module.exports = { cypress/support/component.js import '@cypress/code-coverage/support'; I think this file cypress/plugins/index.js is not required with latest version of cypress. Also not able to see window.coverage object. Let me know how to instrument these. Let me know if I am missing something here. Thanks in advance. |
@shrinidhimayya |
@ShellyDCMS it is the issue with instrumentation , not seeing any proper documentation to instrument code for component tests |
@shrinidhimayya |
its the same , I am still getting this error : "Could not find any coverage information in your application by looking at the window coverage object. Did you forget to instrument your application?" |
Is your feature request related to a problem? Please describe.
i can't find any document about code coverage width component testing, can code-coverage suport it? thank you
The text was updated successfully, but these errors were encountered: