This is a step-by-step description of how I currently (2025-09-18) generate Playwright test coverage in Angular projects without Webpack instrumentation.
In the past, I implemented coverage-istanbul-loader instrumentation with Webpack for UI E2E tests. In the end, I merge the coverage from the Karma tests with the coverage from the Playwright tests (nothing changes there).
My demo project is on GitHub: https://github.com/brabenetz/angular-playwright-coverage For the Git history, I tried to represent my steps as clearly as possible:
The project starts with “ng-new” and ends with a merged test coverage report (Karma & Playwright), which is published via GitHub Actions.
For further details, you can read the sources:
Nothing to do here! As long as the app provides a source map (e.g., with ng serve), the Chrome browser can generate the coverage.
In my projects, I use a small test-utils.ts implementation:
(i) The comparison with a reference screenshot only works locally (mainly due to different OS fonts), so it’s good to only run the comparison if the ENV flag ‘SCREENSHOT_VALIDATION=true’ is set.
Nevertheless, the screenshot comparison is useful for every major change or simply for library updates: Generate reference results before the update, and compare the current state with the old screenshots after the update.
I always add four scripts to the package.json that I use frequently:
Then I need two more libraries:
Karma already supports simple configurations for coverage:
In the Playwright config, the most important thing is to add the monocart-reporter. For merging the coverage data with Karma coverage, you need the ‘json’ reporter.
The coverage should land in the directory coverage/playwright.
In the tests, only the import needs to be swapped. Interesting are the files tests/_shared/app-fixtures.ts and tests/_shared/fixtures/v8-code-coverage.ts that are used instead.
These two files come from the Monocart Reporter example project: https://github.com/edumserrano/playwright-adventures/blob/main/demos/code-coverage-with-monocart-reporter/tests/_shared/app-fixtures.ts
After Karma coverage (with npm run test) and Playwright coverage (with npm run playwright:test-all) have been generated, you should see the reports in the coverage folder:
Important are the JSON files ‘coverage-karma.json’ & ‘coverage-playwright.json’: These need to be merged together in the next step.
I divide the merge into three scripts:
Then I need two more libraries:
In the end, you want to see the Playwright reports in the CI after every build. Using GitHub Actions as an example, it would look like this: