@tracelane/playwright 0.1.0-alpha.1
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/NOTICE +19 -0
- package/README.md +77 -0
- package/dist/fixture.d.ts +21 -0
- package/dist/fixture.d.ts.map +1 -0
- package/dist/fixture.js +50 -0
- package/dist/fixture.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +45 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +37 -0
- package/dist/options.js.map +1 -0
- package/dist/playwright-executor.d.ts +9 -0
- package/dist/playwright-executor.d.ts.map +1 -0
- package/dist/playwright-executor.js +52 -0
- package/dist/playwright-executor.js.map +1 -0
- package/dist/playwright-session.d.ts +36 -0
- package/dist/playwright-session.d.ts.map +1 -0
- package/dist/playwright-session.js +141 -0
- package/dist/playwright-session.js.map +1 -0
- package/dist/reporter.d.ts +19 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +61 -0
- package/dist/reporter.js.map +1 -0
- package/dist/result-status.d.ts +14 -0
- package/dist/result-status.d.ts.map +1 -0
- package/dist/result-status.js +33 -0
- package/dist/result-status.js.map +1 -0
- package/dist/rrweb-bundle.js +141 -0
- package/package.json +78 -0
package/dist/reporter.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// The Playwright Reporter (P1 PRD §B). Registered in playwright.config.ts as
|
|
2
|
+
// `reporter: [['@tracelane/playwright', { mode, outDir }]]`.
|
|
3
|
+
//
|
|
4
|
+
// IMPORTANT: the Reporter does NOT build reports — the per-test HTML build lives
|
|
5
|
+
// in the auto-fixture, which is the only place with a live `page` + `testInfo`.
|
|
6
|
+
// By design the Reporter never touches `page`. Its job is config validation
|
|
7
|
+
// (resolveOptions in the constructor so invalid config surfaces early) and
|
|
8
|
+
// tallying pass/fail for future use.
|
|
9
|
+
//
|
|
10
|
+
// NOTE on captureNetwork: reporter constructor options do NOT propagate to the
|
|
11
|
+
// fixture — they run in separate Playwright worker processes. Setting
|
|
12
|
+
// `captureNetwork: false` here is silently ignored by the fixture's CDP attach.
|
|
13
|
+
// Control the fixture via TRACELANE_CAPTURE_NETWORK=false env var instead (see
|
|
14
|
+
// options.ts resolveOptions for the env contract).
|
|
15
|
+
import { resolveOptions } from './options.js';
|
|
16
|
+
/**
|
|
17
|
+
* tracelane's Playwright reporter. Pair it with the fixture
|
|
18
|
+
* (`import { test } from '@tracelane/playwright/fixture'`) — the fixture records
|
|
19
|
+
* + writes reports; this reporter validates config at startup.
|
|
20
|
+
*/
|
|
21
|
+
export class TraceLaneReporter {
|
|
22
|
+
failed = 0;
|
|
23
|
+
constructor(opts = {}) {
|
|
24
|
+
// Resolve up front so an invalid config surfaces early (throws on bad input).
|
|
25
|
+
resolveOptions(opts);
|
|
26
|
+
// Warn loudly if captureNetwork was explicitly set on the reporter — it
|
|
27
|
+
// cannot be honored here because the fixture runs in a separate Playwright
|
|
28
|
+
// worker process and calls resolveOptions({}) independently. The only way
|
|
29
|
+
// to disable CDP capture is via the TRACELANE_CAPTURE_NETWORK=false env var.
|
|
30
|
+
if (opts.captureNetwork === false) {
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.warn('[tracelane] reporter: captureNetwork:false is ignored — the fixture ' +
|
|
33
|
+
'runs in a separate worker process and cannot see reporter options. ' +
|
|
34
|
+
'Set TRACELANE_CAPTURE_NETWORK=false instead.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** The fixture + Playwright own the run output; this reporter is silent. */
|
|
38
|
+
printsToStdio() {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
onBegin(_config, _suite) {
|
|
42
|
+
this.failed = 0;
|
|
43
|
+
}
|
|
44
|
+
onTestBegin(_test, _result) {
|
|
45
|
+
// No-op: the fixture starts the recorder per test.
|
|
46
|
+
}
|
|
47
|
+
onTestEnd(test, _result) {
|
|
48
|
+
// TestCase.ok() is Playwright's "ended as expected" check (so test.fail()
|
|
49
|
+
// expected-failures count as ok). A not-ok test is what the fixture builds a
|
|
50
|
+
// report for in 'failed' mode.
|
|
51
|
+
if (!test.ok())
|
|
52
|
+
this.failed++;
|
|
53
|
+
}
|
|
54
|
+
onEnd(_result) {
|
|
55
|
+
// No-op: output removed (printsToStdio() is false; console.log here would
|
|
56
|
+
// confuse Playwright which may add its own terminal reporter). The fixture
|
|
57
|
+
// already wrote report files.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export default TraceLaneReporter;
|
|
61
|
+
//# sourceMappingURL=reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6DAA6D;AAC7D,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,4EAA4E;AAC5E,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,+EAA+E;AAC/E,sEAAsE;AACtE,gFAAgF;AAChF,+EAA+E;AAC/E,mDAAmD;AAUnD,OAAO,EAAyB,cAAc,EAAE,MAAM,cAAc,CAAC;AAErE;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACpB,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,OAAyB,EAAE;QACrC,8EAA8E;QAC9E,cAAc,CAAC,IAAI,CAAC,CAAC;QACrB,wEAAwE;QACxE,2EAA2E;QAC3E,0EAA0E;QAC1E,6EAA6E;QAC7E,IAAI,IAAI,CAAC,cAAc,KAAK,KAAK,EAAE,CAAC;YAClC,sCAAsC;YACtC,OAAO,CAAC,IAAI,CACV,sEAAsE;gBACpE,qEAAqE;gBACrE,8CAA8C,CACjD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,OAAmB,EAAE,MAAa;QACxC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,WAAW,CAAC,KAAe,EAAE,OAAmB;QAC9C,mDAAmD;IACrD,CAAC;IAED,SAAS,CAAC,IAAc,EAAE,OAAmB;QAC3C,0EAA0E;QAC1E,6EAA6E;QAC7E,+BAA+B;QAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAmB;QACvB,0EAA0E;QAC1E,2EAA2E;QAC3E,8BAA8B;IAChC,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TestInfo } from '@playwright/test';
|
|
2
|
+
import type { ReportStatus } from '@tracelane/report';
|
|
3
|
+
type PwStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
|
|
4
|
+
/** Map a Playwright `TestResult.status` to a report `ReportStatus`. */
|
|
5
|
+
export declare function mapStatus(status: PwStatus): ReportStatus;
|
|
6
|
+
/**
|
|
7
|
+
* A test "passed" when its actual status equals its expected status — this is
|
|
8
|
+
* Playwright's own definition (it makes `test.fail()` cases, where the expected
|
|
9
|
+
* status is 'failed', count as a pass). The recorder uses this to decide
|
|
10
|
+
* whether to build a report in 'failed' mode (ADR-0005).
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPassed(testInfo: Pick<TestInfo, 'status' | 'expectedStatus'>): boolean;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=result-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-status.d.ts","sourceRoot":"","sources":["../src/result-status.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;AAE7E,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,YAAY,CAYxD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAAC,GAAG,OAAO,CAEvF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Map Playwright's test outcome to @tracelane/report's ReportStatus + decide
|
|
2
|
+
// whether a test counts as "passed" for the recorder's report-build decision.
|
|
3
|
+
//
|
|
4
|
+
// @tracelane/report's ReportStatus union is 'passed' | 'failed' | 'skipped' |
|
|
5
|
+
// 'broken' (verified against @tracelane/report's src/index.ts → types.ts).
|
|
6
|
+
// Playwright's TestResult.status is 'passed' | 'failed' | 'timedOut' |
|
|
7
|
+
// 'skipped' | 'interrupted'. timedOut/interrupted have no direct member, so we
|
|
8
|
+
// map them to 'broken' — the report renders 'broken' as a non-pass that is not
|
|
9
|
+
// a plain assertion failure, which matches a timeout/interrupt.
|
|
10
|
+
/** Map a Playwright `TestResult.status` to a report `ReportStatus`. */
|
|
11
|
+
export function mapStatus(status) {
|
|
12
|
+
switch (status) {
|
|
13
|
+
case 'passed':
|
|
14
|
+
return 'passed';
|
|
15
|
+
case 'failed':
|
|
16
|
+
return 'failed';
|
|
17
|
+
case 'skipped':
|
|
18
|
+
return 'skipped';
|
|
19
|
+
case 'timedOut':
|
|
20
|
+
case 'interrupted':
|
|
21
|
+
return 'broken';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A test "passed" when its actual status equals its expected status — this is
|
|
26
|
+
* Playwright's own definition (it makes `test.fail()` cases, where the expected
|
|
27
|
+
* status is 'failed', count as a pass). The recorder uses this to decide
|
|
28
|
+
* whether to build a report in 'failed' mode (ADR-0005).
|
|
29
|
+
*/
|
|
30
|
+
export function isPassed(testInfo) {
|
|
31
|
+
return testInfo.status === testInfo.expectedStatus;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=result-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-status.js","sourceRoot":"","sources":["../src/result-status.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,uEAAuE;AACvE,+EAA+E;AAC/E,+EAA+E;AAC/E,gEAAgE;AAOhE,uEAAuE;AACvE,MAAM,UAAU,SAAS,CAAC,MAAgB;IACxC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,UAAU,CAAC;QAChB,KAAK,aAAa;YAChB,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAqD;IAC5E,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,cAAc,CAAC;AACrD,CAAC"}
|