Gathering detailed insights and metrics for playwright-test-coverage-native
Gathering detailed insights and metrics for playwright-test-coverage-native
Extends Playwright test to measure code coverage using Playwright's built-in features
npm install playwright-test-coverage-native
Typescript
Module System
Node Version
NPM Version
33
Supply Chain
89.4
Quality
76.4
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
1,439
Last Day
2
Last Week
16
Last Month
97
Last Year
1,041
MIT License
4 Stars
12 Commits
7 Watchers
1 Branches
5 Contributors
Updated on Dec 06, 2024
Minified
Minified + Gzipped
Latest Version
0.3.0
Package Id
playwright-test-coverage-native@0.3.0
Unpacked Size
6.92 kB
Size
2.96 kB
File Count
5
NPM Version
10.8.2
Node Version
20.17.0
Published on
Nov 04, 2024
Cumulative downloads
Total Downloads
Last Day
100%
2
Compared to previous day
Last Week
-33.3%
16
Compared to previous week
Last Month
-4%
97
Compared to previous month
Last Year
161.6%
1,041
Compared to previous year
1
2
Measure test coverage with Playwright.
Its only dependency is @playwright/test
— unlike its alternatives, playwright-test-coverage-native
uses Playwright's
built-in coverage functionality without Istanbul.
Using NPM:
1npm i -D playwright-test-coverage-native
Using PNPM:
1pnpm i -D playwright-test-coverage-native
Add coverageDir
to playwright.config.ts
to set where coverage data should be written to.
For example,
1import { defineConfig, devices } from "playwright-test-coverage-native";
2
3// See https://playwright.dev/docs/test-configuration.
4export default defineConfig({
5 projects: [
6 {
7 name: "chromium",
8 use: {
9 ...devices["Desktop Chrome"],
10 coverageDir: './coverage/tmp', // output location for coverage data
11 coverageSrc: './src', // filter coverage data for only files in ./src (optional)
12 // one of: '@fs', 'localhosturl'. Sadly you'll just have to play around to see which one works
13 coverageSourceMapHandler: '@fs'
14 },
15 },
16 ],
17});
[!NOTE]
Coverage APIs are only supported on Chromium-based browsers.
playwright-test-coverage-native
is a drop-in replacement for @playwright/test
. Edit the import of your test files like this:
1-import { test, expect } from '@playwright/test'; 2+import { test, expect } from 'playwright-test-coverage-native';
If you're brave, you can do the changes in bulk:
1# using GNU coreutils 2find -type f -name '*.test.?s' -exec sed -i -e 's#@playwright/test#playwright-test-coverage-native#' \;
Install c8.
After running playwright test -c playwright.config.ts
,
run c8 report
to print a summary of the coverage.
c8 report
is also used to convert to various formats,
see c8 report --help
for more options.
[!NOTE]
V8 code coverage can be inaccurate due to JavaScript code transformation and source maps, in which case alternatives (which use istanbul) may be preferable.
No vulnerabilities found.
No security vulnerabilities found.