{"library":"playwright-test-coverage","title":"Playwright Test Coverage","description":"Playwright Test Coverage is an extension for the Playwright test framework designed to facilitate code coverage collection from end-to-end tests. Currently stable at version 1.2.12, this library integrates with `babel-plugin-istanbul` for source code instrumentation and `nyc` for managing the test run and generating comprehensive coverage reports. Unlike some other coverage tools, `playwright-test-coverage` requires developers to explicitly instrument their frontend source code during the build process and run their application server via `nyc`. It provides a wrapper around Playwright's `test` and `expect` functions, ensuring that coverage data from the browser context is properly captured and merged. This setup is particularly useful for projects that already leverage Babel for their build pipeline and require detailed E2E coverage metrics.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install playwright-test-coverage"],"cli":null},"imports":["import { test, expect } from 'playwright-test-coverage';","const { test, expect } = require('playwright-test-coverage');","import type { Test, Expect } from 'playwright-test-coverage';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const { test, expect } = require(\"playwright-test-coverage\");\n\ntest(\"basic test with coverage\", async ({ page }) => {\n  // Assume your application is running on localhost:3000,\n  // instrumented with babel-plugin-istanbul, and started via nyc.\n  await page.goto(\"http://localhost:3000/\");\n  // Example: Interact with an element to trigger code execution\n  await page.locator('button').click();\n\n  // Assertions as usual\n  const title = page.locator('h1');\n  await expect(title).toHaveText(\"Welcome to My App\");\n});\n\n// To run:\n// 1. Ensure your frontend code is instrumented with babel-plugin-istanbul.\n// 2. Start your server with nyc: `nyc node your-server-script.js`\n// 3. Run your Playwright tests: `npx playwright test`","lang":"javascript","description":"Demonstrates how to import `test` and `expect` from `playwright-test-coverage` to enable coverage collection in a basic Playwright E2E test, including necessary setup steps.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}