devkit icon indicating copy to clipboard operation
devkit copied to clipboard

Documentation to code coverage

Open philippjenni opened this issue 4 years ago • 5 comments

Is there any documentation how i can use or integrate code coverage for my tests. I use the 'cypress-angular' plugin to test components in an angular sub project. That works fine but i would like use code coverage for the project. The components are loaded with mount and then tested.

philippjenni avatar Nov 16 '21 20:11 philippjenni

Hi @philippjenni, this is in fact an interesting feature that we didn't dive into yet. We would be more than happy if you or anyone else could help us out 😊

Thank you for raising this.

yjaaidi avatar Nov 17 '21 19:11 yjaaidi

I have tried it to integrate with "istanbul-instrumenter-loader". The problem is, that is currently not possible to inject the required coverage webpack to the devserver. There are some examples, how codecoverage is to be integrated with cypress, but it requires always to inject the webpack config.

philippjenni avatar Nov 17 '21 20:11 philippjenni

Just been trying to do this, we get coverage from cypress normally by using the ngx-build-plus library as per this example https://github.com/skylock/cypress-angular-coverage-example would be great if it would respect the coverage.webpack.js file already used for this too

andrew-cunliffe avatar Dec 15 '21 22:12 andrew-cunliffe

I tried to pass the settings to the web server via the webpackConfig property. This works as far as possible. The configuration in the DevWebServer looks OK, but the Coverage variable is not filled during the test, which leads to the message that the instrumentation was not started.

At the moment I have no idea what the problem is.

philippjenni avatar Jan 29 '22 10:01 philippjenni

I have pushed my test repo to https://github.com/philippjenni/angular-library-cypress Any tip on how to get the coverage running is welcome. The coverage with the main project is working.

philippjenni avatar Jan 31 '22 20:01 philippjenni