Skip to content
Discussion options

You must be logged in to vote

Upon further investigation, mxschmitt/playwright-test-coverage seems to demonstrate what I need.

The key is to extend the base Playwright test runner to capture window.__coverage__ and serialize it at the appropriate time. See baseFixtures.ts.

UPDATE Sep 6, 21: I have published playwright-test-coverage npm package which can be used as follows instead of copy-pasting the solution from the repo:

npm i -D playwright-test-coverage
const { test, expect } = require("playwright-test-coverage");

// Use test and expect as usual
test('basic test', async ({ page }) => {
  // Test code
});

Ideally, this should be an option in Playwright itself.

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by anishkny
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants