0

I want to measure code coverage of Angular 12 application. I have Automation test written in Selenium which runs the application deployed on another machine. I have tried the following steps using istanbul:

  1. set source maps to true in angular.json
  2. build the app using ng build --configuration production
  3. instrument the dist code using nyc instrument --in-place dist/
  4. serve the dist folder locally using http-server
  5. Access the application in local browser
  6. Capture the window.__coverage__ object from the browser
  7. Store the object in .nyc_output directory as a json file
  8. generate report using nyc report --reporter=lcov

The generated HTML report contains coverage for dist and dist/webpack:/src etc. The files mentioned when drilled down have the error:

Unable to lookup source: /home/test/code-coverage/ui-analytics/dist/webpack:/src/main.ts (ENOENT: no such file or directory, open '/home/test/code-coverage/ui-analytics/dist/webpack:/src/main.ts') 

Also, the coverage/lcov-report folder, there are weird folders created like webpack:.

If I build without source maps, I get the report of dist folder (the minified files).

Any help will be appreciated!

skeptismo
  • 9
  • 2

0 Answers0