playwright-code-coverage 0.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -0
- package/index.d.ts +2 -0
- package/index.esm.js +191 -0
- package/package.json +28 -0
- package/src/config.d.ts +19 -0
- package/src/config.d.ts.map +1 -0
- package/src/coverage-reporter.d.ts +11 -0
- package/src/coverage-reporter.d.ts.map +1 -0
- package/src/index.d.ts +5 -0
- package/src/index.d.ts.map +1 -0
- package/src/models.d.ts +21 -0
- package/src/models.d.ts.map +1 -0
- package/src/test-with-coverage.d.ts +2 -0
- package/src/test-with-coverage.d.ts.map +1 -0
- package/src/utils/attachment.utils.d.ts +8 -0
- package/src/utils/attachment.utils.d.ts.map +1 -0
- package/src/utils/coverage-map.utils.d.ts +6 -0
- package/src/utils/coverage-map.utils.d.ts.map +1 -0
- package/src/utils/coverage-report.utils.d.ts +5 -0
- package/src/utils/coverage-report.utils.d.ts.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Playwright code coverage
|
|
2
|
+
|
|
3
|
+
Generate istanbul code coverage reports for Playwright tests.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Playwright >= 1.40.0
|
|
8
|
+
- Ensure sourcemaps are enabled for dev server/bundle
|
|
9
|
+
- Run tests with a chromium-based browser
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Install:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm i -D playwright-code-coverage
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Configure:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// playwright.config.ts
|
|
23
|
+
import { defineConfig } from '@playwright/test';
|
|
24
|
+
import { defineCoverageReporterConfig } from 'playwright-code-coverage';
|
|
25
|
+
|
|
26
|
+
export default defineConfig({
|
|
27
|
+
reporter: [
|
|
28
|
+
[
|
|
29
|
+
'playwright-code-coverage',
|
|
30
|
+
defineCoverageReporterConfig({
|
|
31
|
+
workspaceRoot: __dirname,
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Instrument your tests:
|
|
39
|
+
|
|
40
|
+
To enable code coverage for tests you need to use the `testWithCoverage` fixture instead of the regular `test` fixture.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { expect } from '@playwright/test';
|
|
44
|
+
import { testWithCoverage as test } from 'playwright-code-coverage';
|
|
45
|
+
|
|
46
|
+
test('has title', async ({ page }) => {
|
|
47
|
+
await page.goto('/');
|
|
48
|
+
|
|
49
|
+
expect(await page.locator('h1').innerText()).toContain('Welcome');
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can also [extend](https://playwright.dev/docs/test-fixtures#creating-a-fixture) this fixture or [merge]() it.
|
|
54
|
+
|
|
55
|
+
### Generate coverage report:
|
|
56
|
+
|
|
57
|
+
Code coverage is generated after each test command is finished and written to the configured output directory (default: `coverage/playwright-code-coverage`).
|
|
58
|
+
|
|
59
|
+
Default output format is `lcov` but can be configured to use any format supported by `istanbul-reports` like:
|
|
60
|
+
|
|
61
|
+
- `clover`
|
|
62
|
+
- `html`
|
|
63
|
+
- `json`
|
|
64
|
+
- `text`
|
|
65
|
+
|
|
66
|
+
## Supported frameworks
|
|
67
|
+
|
|
68
|
+
In theory this library works with any framework that uses sourcemaps.
|
|
69
|
+
However, only the following frameworks have currently been tested:
|
|
70
|
+
|
|
71
|
+
- `angular 21`
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
### Configuration options
|
|
76
|
+
|
|
77
|
+
| Setting | Description | Default |
|
|
78
|
+
| ----------------- | ------------------------------------------------------------------- | --------------------------------------------------- |
|
|
79
|
+
| `workspaceRoot` | Root folder of project, should be an absolute path | None, this is a required field |
|
|
80
|
+
| `outputDir` | Folder to write the coverage report to | `coverage/playwright-code-coverage` |
|
|
81
|
+
| `baseURL` | URL on which the application lives | `http://localhost:4200` |
|
|
82
|
+
| `bundleLocation` | Location of the bundle folder on disk | None, required when testing with static file server |
|
|
83
|
+
| `includePatterns` | glob patterns for including files in coverage report | `['**/*.ts', '**/*.tsx']` |
|
|
84
|
+
| `excludePatterns` | glob patterns for excluding files in coverage report | `[]` |
|
|
85
|
+
| `reporters` | reporters from `istanbul-reports` executed at the end of test suite | `['lcov']` |
|
|
86
|
+
| `debug` | Prints config at start when set | false |
|
|
87
|
+
|
|
88
|
+
### Configuration examples
|
|
89
|
+
|
|
90
|
+
#### Standard angular app - dev server
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { defineCoverageReporterConfig } from 'playwright-code-coverage';
|
|
94
|
+
|
|
95
|
+
defineCoverageReporterConfig({
|
|
96
|
+
workspaceRoot: __dirname,
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Standard angular app - static file server
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { defineCoverageReporterConfig } from 'playwright-code-coverage';
|
|
104
|
+
|
|
105
|
+
defineCoverageReporterConfig({
|
|
106
|
+
workspaceRoot: __dirname,
|
|
107
|
+
bundleLocation: 'dist/angular-app/browser',
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Angular in nx monorepo
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { workspaceRoot } from '@nx/devkit';
|
|
115
|
+
import { defineCoverageReporterConfig } from 'playwright-code-coverage';
|
|
116
|
+
|
|
117
|
+
defineCoverageReporterConfig({
|
|
118
|
+
workspaceRoot: workspaceRoot,
|
|
119
|
+
includePatterns: ['**/angular/app/**/*.ts'],
|
|
120
|
+
});
|
|
121
|
+
```
|
package/index.d.ts
ADDED
package/index.esm.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { existsSync, rmSync, mkdirSync } from 'fs';
|
|
2
|
+
import libCoverage from 'istanbul-lib-coverage';
|
|
3
|
+
import libReport from 'istanbul-lib-report';
|
|
4
|
+
import reports from 'istanbul-reports';
|
|
5
|
+
import { minimatch } from 'minimatch';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import v8toIstanbul from 'v8-to-istanbul';
|
|
8
|
+
import { test } from '@playwright/test';
|
|
9
|
+
|
|
10
|
+
const COVERAGE_REPORTER_DEFAULTS = {
|
|
11
|
+
outputDir: 'coverage/playwright-code-coverage',
|
|
12
|
+
reporters: ['lcov'],
|
|
13
|
+
baseUrl: 'http://localhost:4200',
|
|
14
|
+
includePatterns: ['**/*.ts', '**/*.tsx'],
|
|
15
|
+
};
|
|
16
|
+
const defineCoverageReporterConfig = (config) => {
|
|
17
|
+
return {
|
|
18
|
+
workspaceRoot: config.workspaceRoot ?? '',
|
|
19
|
+
outputDir: config.outputDir ?? COVERAGE_REPORTER_DEFAULTS.outputDir,
|
|
20
|
+
baseURL: config.baseURL ?? COVERAGE_REPORTER_DEFAULTS.baseUrl,
|
|
21
|
+
reporters: config.reporters ?? COVERAGE_REPORTER_DEFAULTS.reporters,
|
|
22
|
+
bundleLocation: config.bundleLocation ?? '',
|
|
23
|
+
includePatterns: config.includePatterns ?? COVERAGE_REPORTER_DEFAULTS.includePatterns,
|
|
24
|
+
excludePatterns: config.excludePatterns ?? [],
|
|
25
|
+
debug: config.debug ?? false,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const coverageFileKey = 'coverage';
|
|
30
|
+
const marshallCoverage = (coverage) => {
|
|
31
|
+
return {
|
|
32
|
+
body: Buffer.from(JSON.stringify(coverage)),
|
|
33
|
+
contentType: 'application/json',
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const unmarshallCoverage = (attachments) => {
|
|
37
|
+
const coverageAttachment = attachments.find(a => a.name === coverageFileKey);
|
|
38
|
+
if (coverageAttachment?.body) {
|
|
39
|
+
return JSON.parse(coverageAttachment.body.toString());
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const postProcessIstanbulCoverMap = (coverageMapData, config) => {
|
|
45
|
+
const newCoverMapData = {};
|
|
46
|
+
Object.entries(coverageMapData).forEach(entries => {
|
|
47
|
+
const [key, entry] = entries;
|
|
48
|
+
let newKey;
|
|
49
|
+
if (config.bundleLocation) {
|
|
50
|
+
newKey = key.replace(`/${config.bundleLocation}`, '');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const doubleSlashRemoved = config.baseURL.replace('//', '/');
|
|
54
|
+
newKey = key.replace(`/${doubleSlashRemoved}`, '');
|
|
55
|
+
}
|
|
56
|
+
newCoverMapData[newKey] = entry;
|
|
57
|
+
});
|
|
58
|
+
Object.values(coverageMapData).forEach(coverage => {
|
|
59
|
+
if (config.bundleLocation) {
|
|
60
|
+
coverage.path = coverage.path.replace(`/${config.bundleLocation}`, '');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const doubleSlashRemoved = config.baseURL.replace('//', '/');
|
|
64
|
+
coverage.path = coverage.path.replace(`/${doubleSlashRemoved}`, '');
|
|
65
|
+
});
|
|
66
|
+
return newCoverMapData;
|
|
67
|
+
};
|
|
68
|
+
const filterCoverageMap = (coverageMap, config) => {
|
|
69
|
+
const filteredCoverage = libCoverage.createCoverageMap();
|
|
70
|
+
coverageMap.files().forEach(filePath => {
|
|
71
|
+
const isIncluded = config.includePatterns.some(pattern => minimatch(filePath, pattern));
|
|
72
|
+
const isExcluded = config.excludePatterns.some(pattern => minimatch(filePath, pattern));
|
|
73
|
+
if (isIncluded && !isExcluded) {
|
|
74
|
+
filteredCoverage.addFileCoverage(coverageMap.fileCoverageFor(filePath));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return filteredCoverage;
|
|
78
|
+
};
|
|
79
|
+
const generateReports = (coverageMap, config) => {
|
|
80
|
+
const context = libReport.createContext({
|
|
81
|
+
dir: `${config.workspaceRoot}/${config.outputDir}`,
|
|
82
|
+
coverageMap,
|
|
83
|
+
});
|
|
84
|
+
config.reporters.forEach(reportType => {
|
|
85
|
+
const report = reports.create(reportType, {
|
|
86
|
+
projectRoot: config.workspaceRoot,
|
|
87
|
+
});
|
|
88
|
+
report.execute(context);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const isBaseURL = (url, config) => {
|
|
93
|
+
return url.startsWith(config.baseURL);
|
|
94
|
+
};
|
|
95
|
+
const isFsPath = (path) => {
|
|
96
|
+
// Not source files in angular, pain to map
|
|
97
|
+
return path.indexOf('@fs') > 0;
|
|
98
|
+
};
|
|
99
|
+
// Only map in case of "bundled angular app"
|
|
100
|
+
// Bundled js in this mode does not contain inline sourcemaps
|
|
101
|
+
// So we need this for v8ToIstanbull to handle path resolution
|
|
102
|
+
const mapCoverageReportToScriptPath = (coverageReport, config) => {
|
|
103
|
+
if (config.bundleLocation) {
|
|
104
|
+
const urlObj = new URL(coverageReport.url);
|
|
105
|
+
const { pathname } = urlObj;
|
|
106
|
+
return join(`${config.workspaceRoot}/${config.bundleLocation}`, pathname);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return coverageReport.url;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const mapPlaywrightCoverageToIstanbul = async (coverageReport, config) => {
|
|
113
|
+
if (isFsPath(coverageReport.url) ||
|
|
114
|
+
!isBaseURL(coverageReport.url, config) ||
|
|
115
|
+
!coverageReport.source ||
|
|
116
|
+
!(coverageReport.functions.length > 0)) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const converter = v8toIstanbul(mapCoverageReportToScriptPath(coverageReport, config), 0, coverageReport.source ? { source: coverageReport.source } : undefined);
|
|
120
|
+
await converter.load();
|
|
121
|
+
converter.applyCoverage(coverageReport.functions);
|
|
122
|
+
return converter.toIstanbul();
|
|
123
|
+
};
|
|
124
|
+
const mapReportsToMapData = async (coverageReports, config) => {
|
|
125
|
+
const istanbulCoverage = await Promise.all(coverageReports.map(async (entry) => mapPlaywrightCoverageToIstanbul(entry, config)));
|
|
126
|
+
return istanbulCoverage.filter(mappedData => mappedData !== null);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
class CoverageReporter {
|
|
130
|
+
#coverageMap = libCoverage.createCoverageMap();
|
|
131
|
+
#config;
|
|
132
|
+
constructor(options) {
|
|
133
|
+
if (!options) {
|
|
134
|
+
throw new Error('No configuration provided for coverage reporter');
|
|
135
|
+
}
|
|
136
|
+
if (!options.workspaceRoot) {
|
|
137
|
+
throw new Error('No project root provided for coverage reporter');
|
|
138
|
+
}
|
|
139
|
+
if (!options.includePatterns || !options.includePatterns.length) {
|
|
140
|
+
throw new Error('No include patterns provided for coverage reporter');
|
|
141
|
+
}
|
|
142
|
+
this.#config = defineCoverageReporterConfig(options);
|
|
143
|
+
if (this.#config.debug) {
|
|
144
|
+
console.info('Coverage reporter configuration:', this.#config);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
onBegin() {
|
|
148
|
+
console.info('Starting coverage reporter...');
|
|
149
|
+
const outputDir = `${this.#config.workspaceRoot}/${this.#config.outputDir}`;
|
|
150
|
+
if (existsSync(outputDir)) {
|
|
151
|
+
rmSync(outputDir, { recursive: true, force: true });
|
|
152
|
+
}
|
|
153
|
+
mkdirSync(outputDir, { recursive: true });
|
|
154
|
+
}
|
|
155
|
+
async onTestEnd(test, result) {
|
|
156
|
+
if (result.attachments) {
|
|
157
|
+
try {
|
|
158
|
+
const coverageReport = unmarshallCoverage(result.attachments);
|
|
159
|
+
const coverageMapData = await mapReportsToMapData(coverageReport, this.#config);
|
|
160
|
+
coverageMapData.forEach((map) => {
|
|
161
|
+
const postProcessedCoverageMap = postProcessIstanbulCoverMap(map, this.#config);
|
|
162
|
+
this.#coverageMap.merge(postProcessedCoverageMap);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error(`Failed to process coverage data for "${test.title}" :`, error);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async onEnd() {
|
|
171
|
+
const filteredCoverageMap = filterCoverageMap(this.#coverageMap, this.#config);
|
|
172
|
+
generateReports(filteredCoverageMap, this.#config);
|
|
173
|
+
console.info('Coverage reports generated...');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const testWithCoverage = test.extend({
|
|
178
|
+
page: async ({ context, page }, use, testInfo) => {
|
|
179
|
+
if (context.browser()?.browserType()?.name() !== 'chromium') {
|
|
180
|
+
return use(page);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
await page.coverage.startJSCoverage({ resetOnNavigation: false });
|
|
184
|
+
await use(page);
|
|
185
|
+
const coverage = await page.coverage.stopJSCoverage();
|
|
186
|
+
await testInfo.attach(coverageFileKey, marshallCoverage(coverage));
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export { COVERAGE_REPORTER_DEFAULTS, CoverageReporter, CoverageReporter as default, defineCoverageReporterConfig, testWithCoverage };
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "playwright-code-coverage",
|
|
3
|
+
"version": "0.0.0-alpha",
|
|
4
|
+
"description": "Reporter for generating istanbul coverage reports for playwright tests ",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"playwright",
|
|
7
|
+
"coverage",
|
|
8
|
+
"istanbul",
|
|
9
|
+
"reporter"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=20.0.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@playwright/test": "^1.40.0"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"istanbul-lib-coverage": "^3.2.2",
|
|
19
|
+
"istanbul-lib-report": "^3.0.1",
|
|
20
|
+
"istanbul-reports": "^3.2.0",
|
|
21
|
+
"minimatch": "^10.1.2",
|
|
22
|
+
"v8-to-istanbul": "^9.3.0"
|
|
23
|
+
},
|
|
24
|
+
"module": "./index.esm.js",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./index.esm.js",
|
|
27
|
+
"types": "./index.d.ts"
|
|
28
|
+
}
|
package/src/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReportType } from 'istanbul-reports';
|
|
2
|
+
export type CoverageReporterConfig = {
|
|
3
|
+
workspaceRoot: string;
|
|
4
|
+
outputDir: string;
|
|
5
|
+
baseURL: string;
|
|
6
|
+
bundleLocation: string;
|
|
7
|
+
includePatterns: string[];
|
|
8
|
+
excludePatterns: string[];
|
|
9
|
+
reporters: ReportType[];
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const COVERAGE_REPORTER_DEFAULTS: {
|
|
13
|
+
outputDir: string;
|
|
14
|
+
reporters: ReportType[];
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
includePatterns: string[];
|
|
17
|
+
};
|
|
18
|
+
export declare const defineCoverageReporterConfig: (config: Partial<CoverageReporterConfig>) => CoverageReporterConfig;
|
|
19
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../libs/playwright-code-coverage/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,0BAA0B;;eAEd,UAAU,EAAE;;;CAGpC,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,QAAQ,OAAO,CAAC,sBAAsB,CAAC,KACtC,sBAWF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
import { CoverageReporterConfig } from './config';
|
|
3
|
+
export declare class CoverageReporter implements Reporter {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(options?: Partial<CoverageReporterConfig>);
|
|
6
|
+
onBegin(): void;
|
|
7
|
+
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
8
|
+
onEnd(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export default CoverageReporter;
|
|
11
|
+
//# sourceMappingURL=coverage-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-reporter.d.ts","sourceRoot":"","sources":["../../../../libs/playwright-code-coverage/src/coverage-reporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGhF,OAAO,EAAE,sBAAsB,EAAgC,MAAM,UAAU,CAAC;AAShF,qBAAa,gBAAiB,YAAW,QAAQ;;gBAInC,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAiBrD,OAAO;IASD,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IAe5C,KAAK;CAKZ;AAED,eAAe,gBAAgB,CAAC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/playwright-code-coverage/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,cAAc,sBAAsB,CAAC"}
|
package/src/models.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CoverageReport = {
|
|
2
|
+
url: string;
|
|
3
|
+
scriptId: string;
|
|
4
|
+
source?: string;
|
|
5
|
+
functions: Array<{
|
|
6
|
+
functionName: string;
|
|
7
|
+
isBlockCoverage: boolean;
|
|
8
|
+
ranges: Array<{
|
|
9
|
+
count: number;
|
|
10
|
+
startOffset: number;
|
|
11
|
+
endOffset: number;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
export type Attachment = {
|
|
16
|
+
name: string;
|
|
17
|
+
contentType: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
body?: Buffer;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../libs/playwright-code-coverage/src/models.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,OAAO,CAAC;QACzB,MAAM,EAAE,KAAK,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,SAAS,EAAE,MAAM,CAAC;SACnB,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const testWithCoverage: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
2
|
+
//# sourceMappingURL=test-with-coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-with-coverage.d.ts","sourceRoot":"","sources":["../../../../libs/playwright-code-coverage/src/test-with-coverage.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,6OAa3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Attachment, CoverageReport } from '../models';
|
|
2
|
+
export declare const coverageFileKey = "coverage";
|
|
3
|
+
export declare const marshallCoverage: (coverage: CoverageReport[]) => {
|
|
4
|
+
body: Buffer<ArrayBuffer>;
|
|
5
|
+
contentType: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const unmarshallCoverage: (attachments: Attachment[]) => CoverageReport[];
|
|
8
|
+
//# sourceMappingURL=attachment.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.utils.d.ts","sourceRoot":"","sources":["../../../../../libs/playwright-code-coverage/src/utils/attachment.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvD,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C,eAAO,MAAM,gBAAgB,GAAI,UAAU,cAAc,EAAE;;;CAK1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,aAAa,UAAU,EAAE,qBAM3D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CoverageMap, CoverageMapData } from 'istanbul-lib-coverage';
|
|
2
|
+
import { CoverageReporterConfig } from '../config';
|
|
3
|
+
export declare const postProcessIstanbulCoverMap: (coverageMapData: CoverageMapData, config: CoverageReporterConfig) => CoverageMapData;
|
|
4
|
+
export declare const filterCoverageMap: (coverageMap: CoverageMap, config: CoverageReporterConfig) => CoverageMap;
|
|
5
|
+
export declare const generateReports: (coverageMap: CoverageMap, config: CoverageReporterConfig) => void;
|
|
6
|
+
//# sourceMappingURL=coverage-map.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-map.utils.d.ts","sourceRoot":"","sources":["../../../../../libs/playwright-code-coverage/src/utils/coverage-map.utils.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIlF,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,eAAO,MAAM,2BAA2B,GACtC,iBAAiB,eAAe,EAChC,QAAQ,sBAAsB,KAC7B,eAyBF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,aAAa,WAAW,EACxB,QAAQ,sBAAsB,KAC7B,WAYF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,aAAa,WAAW,EAAE,QAAQ,sBAAsB,KAAG,IAa1F,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CoverageMapData } from 'istanbul-lib-coverage';
|
|
2
|
+
import { CoverageReporterConfig } from '../config';
|
|
3
|
+
import { CoverageReport } from '../models';
|
|
4
|
+
export declare const mapReportsToMapData: (coverageReports: CoverageReport[], config: CoverageReporterConfig) => Promise<CoverageMapData[]>;
|
|
5
|
+
//# sourceMappingURL=coverage-report.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-report.utils.d.ts","sourceRoot":"","sources":["../../../../../libs/playwright-code-coverage/src/utils/coverage-report.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAkD3C,eAAO,MAAM,mBAAmB,GAC9B,iBAAiB,cAAc,EAAE,EACjC,QAAQ,sBAAsB,KAC7B,OAAO,CAAC,eAAe,EAAE,CAK3B,CAAC"}
|