playwright-test-coverage-native
Advanced tools
Comparing version
@@ -20,3 +20,3 @@ const fsPromises = require("node:fs/promises"); | ||
const absPath = path.resolve("."); | ||
urlReplacer = (url) => url.replace(/http:\/\/localhost:\d+/, absPath); | ||
urlReplacer = (url) => url.replace(/http:\/\/(.+\.)?localhost:\d+/, absPath); | ||
} | ||
@@ -23,0 +23,0 @@ |
{ | ||
"name": "playwright-test-coverage-native", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Extends Playwright for measuring code-coverage (built-in v8 coverage, no Istanbul)", | ||
@@ -26,2 +26,2 @@ "keywords": [ | ||
} | ||
} | ||
} |
@@ -52,2 +52,18 @@ # playwright-test-coverage-native | ||
## Usage | ||
`playwright-test-coverage-native` is a drop-in replacement for `@playwright/test`. Edit the import of your test files like this: | ||
```diff | ||
-import { test, expect } from '@playwright/test'; | ||
+import { test, expect } from 'playwright-test-coverage-native'; | ||
``` | ||
If you're brave, you can do the changes in bulk: | ||
```shell | ||
# using GNU coreutils | ||
find -type f -name '*.test.?s' -exec sed -i -e 's#@playwright/test#playwright-test-coverage-native#' \; | ||
``` | ||
## Post-processing | ||
@@ -64,3 +80,7 @@ | ||
> [!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. | ||
- https://github.com/anishkny/playwright-test-coverage (requires [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) instrumentation) | ||
- https://github.com/mxschmitt/playwright-test-coverage (requires [vite-plugin-istanbul](https://github.com/ifaxity/vite-plugin-istanbul)) |
7089
9.92%85
30.77%