@piwitests/reporter 0.51.0 → 0.53.0
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/dist/cli/index.js +3 -1
- package/dist/global-setup-module.js +22 -5
- package/dist/index.d.ts +41 -3
- package/dist/index.js +4670 -3485
- package/dist/internal/capture/attachments.d.ts +4 -0
- package/dist/internal/capture/attachments.js +8 -0
- package/dist/internal/capture/capture-fixtures.d.ts +39 -10
- package/dist/internal/capture/capture-fixtures.js +424 -76
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -480,7 +480,7 @@ var DEFAULTS = {
|
|
|
480
480
|
// Off by default: the page inventory reads control and link names from every
|
|
481
481
|
// visited page, so it stays opt-in until a project turns it on.
|
|
482
482
|
capturePageInventory: false,
|
|
483
|
-
// Off by default: JavaScript coverage
|
|
483
|
+
// Off by default: JavaScript coverage adds time to every test, so a scheduled job opts in.
|
|
484
484
|
captureCodeReach: false,
|
|
485
485
|
captureServerTraces: true,
|
|
486
486
|
captureResources: true,
|
|
@@ -525,6 +525,8 @@ var PIWI_ENV_KEYS = {
|
|
|
525
525
|
capturePageInventory: "PIWI_CAPTURE_PAGE_INVENTORY",
|
|
526
526
|
captureCodeReach: "PIWI_CAPTURE_CODE_REACH",
|
|
527
527
|
codeReachRoots: "PIWI_CODE_REACH_ROOTS",
|
|
528
|
+
coverageBrowser: "PIWI_COVERAGE_BROWSER",
|
|
529
|
+
coverageServer: "PIWI_COVERAGE_SERVER",
|
|
528
530
|
captureServerTraces: "PIWI_CAPTURE_SERVER_TRACES",
|
|
529
531
|
captureResources: "PIWI_CAPTURE_RESOURCES",
|
|
530
532
|
leakCheck: "PIWI_LEAK_CHECK",
|
|
@@ -80,7 +80,7 @@ var DEFAULTS = {
|
|
|
80
80
|
// Off by default: the page inventory reads control and link names from every
|
|
81
81
|
// visited page, so it stays opt-in until a project turns it on.
|
|
82
82
|
capturePageInventory: false,
|
|
83
|
-
// Off by default: JavaScript coverage
|
|
83
|
+
// Off by default: JavaScript coverage adds time to every test, so a scheduled job opts in.
|
|
84
84
|
captureCodeReach: false,
|
|
85
85
|
captureServerTraces: true,
|
|
86
86
|
captureResources: true,
|
|
@@ -125,6 +125,8 @@ var PIWI_ENV_KEYS = {
|
|
|
125
125
|
capturePageInventory: "PIWI_CAPTURE_PAGE_INVENTORY",
|
|
126
126
|
captureCodeReach: "PIWI_CAPTURE_CODE_REACH",
|
|
127
127
|
codeReachRoots: "PIWI_CODE_REACH_ROOTS",
|
|
128
|
+
coverageBrowser: "PIWI_COVERAGE_BROWSER",
|
|
129
|
+
coverageServer: "PIWI_COVERAGE_SERVER",
|
|
128
130
|
captureServerTraces: "PIWI_CAPTURE_SERVER_TRACES",
|
|
129
131
|
captureResources: "PIWI_CAPTURE_RESOURCES",
|
|
130
132
|
leakCheck: "PIWI_LEAK_CHECK",
|
|
@@ -208,6 +210,13 @@ function resolveOptions(raw) {
|
|
|
208
210
|
desktopDiscovered = true;
|
|
209
211
|
}
|
|
210
212
|
}
|
|
213
|
+
const coverage = { ...mergedRaw.coverage };
|
|
214
|
+
const coverageBrowser = env[PIWI_ENV_KEYS.coverageBrowser];
|
|
215
|
+
const coverageServer = env[PIWI_ENV_KEYS.coverageServer];
|
|
216
|
+
if (coverage.browser === void 0 && coverageBrowser)
|
|
217
|
+
coverage.browser = coverageBrowser;
|
|
218
|
+
if (coverage.server === void 0 && coverageServer) coverage.server = coverageServer;
|
|
219
|
+
if (coverage.browser !== void 0 || coverage.server !== void 0) mergedRaw.coverage = coverage;
|
|
211
220
|
const opts = { ...DEFAULTS, ...mergedRaw };
|
|
212
221
|
if (env[PIWI_ENV_KEYS.verbose] !== void 0) opts.verbose = env[PIWI_ENV_KEYS.verbose] === "true";
|
|
213
222
|
return opts;
|
|
@@ -807,14 +816,22 @@ function baseUrlFromConfig(config) {
|
|
|
807
816
|
return null;
|
|
808
817
|
}
|
|
809
818
|
var INSTRUMENTATION_FETCH_TIMEOUT_MS = 5e3;
|
|
819
|
+
function instrumentationManifestUrls(baseUrl) {
|
|
820
|
+
const base = new URL(baseUrl);
|
|
821
|
+
const root = new URL(INSTRUMENTATION_MANIFEST_PATH, base).toString();
|
|
822
|
+
const path6 = base.pathname.replace(/\/+$/, "");
|
|
823
|
+
return path6 ? [new URL(`${path6}${INSTRUMENTATION_MANIFEST_PATH}`, base).toString(), root] : [root];
|
|
824
|
+
}
|
|
810
825
|
async function fetchInstrumentationManifest(baseUrl, fetchImpl = fetch) {
|
|
811
826
|
try {
|
|
812
827
|
const probe = await fetchImpl(baseUrl, { signal: AbortSignal.timeout(INSTRUMENTATION_FETCH_TIMEOUT_MS) });
|
|
813
828
|
if (!hasInstrumentationHeader(probe.headers)) return null;
|
|
814
|
-
const manifestUrl
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
829
|
+
for (const manifestUrl of instrumentationManifestUrls(baseUrl)) {
|
|
830
|
+
const res = await fetchImpl(manifestUrl, { signal: AbortSignal.timeout(INSTRUMENTATION_FETCH_TIMEOUT_MS) });
|
|
831
|
+
const manifest = res.ok ? parseManifestJson(await res.text()) : null;
|
|
832
|
+
if (manifest) return manifest;
|
|
833
|
+
}
|
|
834
|
+
return null;
|
|
818
835
|
} catch {
|
|
819
836
|
return null;
|
|
820
837
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { PlaywrightTestConfig, Locator, TestType, Page, Fixtures, PlaywrightTest
|
|
|
3
3
|
export { PlaywrightTestConfig } from '@playwright/test';
|
|
4
4
|
export { PiwiFixtures, PiwiWorkerFixtures, extendPiwiFixtures, piwiFixtures } from './internal/capture/capture-fixtures.js';
|
|
5
5
|
import '@piwitests/picker-dom';
|
|
6
|
+
import '@piwitests/core/page-interaction';
|
|
6
7
|
import '@piwitests/core/wire';
|
|
7
8
|
import '@piwitests/core/code-reach';
|
|
8
9
|
|
|
@@ -76,10 +77,11 @@ interface PiwiDashboardOptions {
|
|
|
76
77
|
* dev server's module URLs or the bundle's source maps. It answers "which
|
|
77
78
|
* tests reach this file?" for test selection, change coverage and
|
|
78
79
|
* `piwi preflight`. Only repository-relative file paths are sent. Chromium only;
|
|
79
|
-
* other browsers record nothing. It
|
|
80
|
+
* other browsers record nothing. It adds time to every test, so run it on
|
|
80
81
|
* one scheduled job rather than every run. **Defaults to `false`** — opt in
|
|
81
|
-
* with `captureCodeReach: true` (or `PIWI_CAPTURE_CODE_REACH=true`)
|
|
82
|
-
* Automatically disabled when
|
|
82
|
+
* with `captureCodeReach: true` (or `PIWI_CAPTURE_CODE_REACH=true`), the
|
|
83
|
+
* same as `coverage.browser: 'files'`. Automatically disabled when
|
|
84
|
+
* `collectPerformanceMetrics` is `false`.
|
|
83
85
|
*/
|
|
84
86
|
captureCodeReach?: boolean;
|
|
85
87
|
/**
|
|
@@ -90,6 +92,34 @@ interface PiwiDashboardOptions {
|
|
|
90
92
|
* config's directory (Nuxt: `['app']`).
|
|
91
93
|
*/
|
|
92
94
|
codeReachRoots?: string[];
|
|
95
|
+
/**
|
|
96
|
+
* Record, per test, which source code ran, in the browser and in the
|
|
97
|
+
* backend, and send it with the test as its coverage. Rides the capture
|
|
98
|
+
* fixtures. Off on both sides unless set, and automatically disabled when
|
|
99
|
+
* `collectPerformanceMetrics` is `false`.
|
|
100
|
+
*/
|
|
101
|
+
coverage?: {
|
|
102
|
+
/**
|
|
103
|
+
* What the browser side records: `'files'`, the application files whose
|
|
104
|
+
* functions ran, from Chromium's JavaScript coverage, which is what
|
|
105
|
+
* `captureCodeReach: true` records; `'off'` records nothing. Only paths are
|
|
106
|
+
* sent. Defaults to `'off'`. Can also be set with `PIWI_COVERAGE_BROWSER`.
|
|
107
|
+
*/
|
|
108
|
+
browser?: 'off' | 'files';
|
|
109
|
+
/**
|
|
110
|
+
* What the server side records, from a backend built with Piwi's coverage
|
|
111
|
+
* instrumentation (ASP.NET Core: `-p:PiwiCoverage=true`), which names each
|
|
112
|
+
* request's coverage on its response: `'files'` sends the backend files
|
|
113
|
+
* each test ran, `'functions'` adds the start and end line of each function
|
|
114
|
+
* that ran, `'lines'` adds the executed lines. The reporter collects a
|
|
115
|
+
* test's coverage from the backend after the test ends, never in the test,
|
|
116
|
+
* and at the end of the run sends the run's coverage of the backend too.
|
|
117
|
+
* Line numbers are sent with `'functions'` and `'lines'` only, never source
|
|
118
|
+
* code or hit counts. Defaults to `'off'`. Can also be set with
|
|
119
|
+
* `PIWI_COVERAGE_SERVER`.
|
|
120
|
+
*/
|
|
121
|
+
server?: 'off' | 'files' | 'functions' | 'lines';
|
|
122
|
+
};
|
|
93
123
|
/**
|
|
94
124
|
* Capture server-side spans for each API/document request the test makes,
|
|
95
125
|
* read from the `X-Piwi-Trace` response header emitted by a Piwi
|
|
@@ -442,6 +472,14 @@ declare class PiwiDashboardReporter {
|
|
|
442
472
|
private artifactBytes;
|
|
443
473
|
/** The run's resource report for the dashboard, built in `onEnd`. */
|
|
444
474
|
private resourceReport;
|
|
475
|
+
/** The coverage the options switch on, per runtime. */
|
|
476
|
+
private readonly coverageSettings;
|
|
477
|
+
/** Each test's coverage, when browser or server coverage is on; set in `onBegin`. */
|
|
478
|
+
private coverage;
|
|
479
|
+
/** Tells when the run's last test ended, while server coverage is on. */
|
|
480
|
+
private lastTestWatch;
|
|
481
|
+
/** Result events that stream once their test's server coverage is in. */
|
|
482
|
+
private coverageSends;
|
|
445
483
|
private httpClient;
|
|
446
484
|
private uploader;
|
|
447
485
|
private fileHandler;
|