@tracelane/playwright 0.1.0-alpha.1 → 0.1.0-alpha.2

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -51,8 +51,8 @@ Run your suite. On a failing test you get a single `.html` file at `./tracelane-
51
51
 
52
52
  ## How it works
53
53
 
54
- - **The fixture** owns the recording. It is the only place with a live `page` + `testInfo`, so it injects the rrweb bundle (via `context.addInitScript`, so fresh pages and post-navigation documents are covered), starts the recorder before your test body, and — after it — builds + writes the report. It reuses `@tracelane/core`'s recorder and `@tracelane/report`'s HTML builder.
55
- - **The reporter** owns config + the end-of-run summary. By design it never touches `page`.
54
+ - **The fixture** owns the recording. It is the only place with a live `page` + `testInfo`, so it injects the rrweb bundle via `context.addInitScript` AND hooks `page.on('framenavigated')` to call `recorder.reinject` on every main-frame navigation so recording continues across navigations (each navigation emits a `tracelane.nav` boundary marker in the replay). It starts the recorder before your test body, and — after it — builds + writes the report. It reuses `@tracelane/core`'s recorder and `@tracelane/report`'s HTML builder.
55
+ - **The reporter** owns config only: it validates options at startup and bridges them to the fixture via `TRACELANE_*` env vars. By design it never touches `page`, prints nothing, and produces no end-of-run summary (the fixture writes the per-test reports).
56
56
  - **Failed-network capture** uses CDP on Chromium (4xx/5xx responses and no-response failures are surfaced into the report's network panel). On Firefox/WebKit it degrades silently to rrweb + console.
57
57
  - **Parallel-safe**: report filenames are namespaced by the Playwright **project name** and carry a millisecond timestamp. Different projects are isolated by name; parallel workers *within one project* share the project-name segment and rely on the timestamp (plus spec + title) to stay distinct.
58
58
  - **Coexists** with Playwright's own `trace` — keep `trace: 'on-first-retry'` if you like; tracelane writes a separate, self-contained artifact.
@@ -63,15 +63,21 @@ Run your suite. On a failing test you get a single `.html` file at `./tracelane-
63
63
  | --- | --- | --- |
64
64
  | `mode` | `'failed'` | `'failed'` writes a report only on failure; `'all'` writes one for every test. Overridable with `TRACELANE_MODE`. |
65
65
  | `outDir` | `'./tracelane-reports'` | Where reports are written. Overridable with `TRACELANE_OUT_DIR`. |
66
- | `captureNetwork` | `true` | CDP failed-network capture (Chromium-only). |
66
+ | `captureNetwork` | `true` | CDP failed-network capture (Chromium-only). Overridable with `TRACELANE_CAPTURE_NETWORK`. |
67
67
 
68
- > The reporter and the fixture both resolve options independently; the env vars (`TRACELANE_MODE`, `TRACELANE_OUT_DIR`) are the reliable way to keep them in lockstep across the two when you need a non-default `outDir`.
68
+ > Reporter options (`mode`, `outDir`, `captureNetwork`) are honored by the fixture the reporter bridges them to `TRACELANE_MODE` / `TRACELANE_OUT_DIR` / `TRACELANE_CAPTURE_NETWORK` at startup (only when those env vars are not already set). An explicit env var always wins over the reporter option.
69
69
 
70
70
  ## What this is NOT
71
71
 
72
72
  - Not a SaaS. There is no upload, no signup, no dashboard, no telemetry. The artifact is a single HTML file on your filesystem.
73
73
  - Not a replacement for Playwright's trace viewer — it's a complementary, self-contained replay you can hand to anyone with a browser, no `npx playwright show-trace` required.
74
74
 
75
+ ## Limitations
76
+
77
+ **Content-Security-Policy**: rrweb capture requires in-page script evaluation. If a page's CSP blocks `'unsafe-eval'`, capture degrades gracefully — the test still runs and completes normally, a warning is logged, but no replay is recorded for that page.
78
+
79
+ **Cross-origin navigations**: buffered rrweb events are rescued across same-origin hard navigations via a `pagehide` → `sessionStorage` flush. Cross-origin hard navigations are a known edge case — `sessionStorage` is per-origin, so events buffered immediately before a cross-origin navigation may be lost.
80
+
75
81
  ## License
76
82
 
77
83
  Apache-2.0. See [`NOTICE`](./NOTICE) for bundled third-party software (the rrweb fork + console plugin).
package/dist/fixture.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // The fixture straddles `use()`: it starts capture BEFORE the test body runs,
8
8
  // yields with `use()`, then finalizes + writes the report AFTER. This is the
9
9
  // only place with a live `page` + `testInfo`, which is why the report build
10
- // lives here (the Reporter, Task 11, owns only config + summary).
10
+ // lives here (the Reporter owns only config: validation + the options→env bridge).
11
11
  import { test as base, expect } from '@playwright/test';
12
12
  import { loadRrwebBundle } from '@tracelane/core';
13
13
  import { resolveOptions } from './options.js';
@@ -1 +1 @@
1
- {"version":3,"file":"fixture.js","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,kEAAkE;AAElE,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAuB,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAKrF,MAAM,mBAAmB,GAAiB,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,EAAE,IAAI,EAAkB,EACxB,GAAwB,EACxB,QAAkB,EAClB,eAA6B,mBAAmB;IAEhD,MAAM,OAAO,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;IACnC,IAAI,OAAmC,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACzD,qBAAqB;QACrB,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,WAAW,CAAC,OAAO,EAAE,EAAE,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AC,EAAE,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;IACnC,IAAI,OAAmC,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACzD,qBAAqB;QACrB,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,WAAW,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,mJAAmJ;AACnJ,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAsB;IACnD,SAAS,EAAE;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;YAChC,MAAM,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC;QACD,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;KACzC;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/options.d.ts CHANGED
@@ -15,10 +15,10 @@ export interface TraceLaneOptions {
15
15
  * Capture failed network requests via CDP (Chromium-only). Default `true`.
16
16
  * Routed into the report's network panel through the rrweb console plugin.
17
17
  *
18
- * **Cross-process note**: reporter constructor options are not propagated to
19
- * the fixture (they run in separate Playwright worker processes). Setting
20
- * `captureNetwork: false` on the reporter has no effect on the fixture's CDP
21
- * capture. To disable CDP capture in the fixture, set the env var:
18
+ * The reporter bridges this option to `TRACELANE_CAPTURE_NETWORK` at startup
19
+ * (only when that env var is not already set), so the fixture honors it. An
20
+ * explicit `TRACELANE_CAPTURE_NETWORK` env var always wins over this option.
21
+ * To force-disable CDP capture regardless of reporter config, set:
22
22
  * `TRACELANE_CAPTURE_NETWORK=false` before running Playwright.
23
23
  */
24
24
  captureNetwork?: boolean;
@@ -36,9 +36,9 @@ export interface ResolvedOptions {
36
36
  * invalid `TRACELANE_MODE` is ignored. `env` is injectable for testing.
37
37
  *
38
38
  * `TRACELANE_CAPTURE_NETWORK=false` (case-insensitive) disables CDP network
39
- * capture in the fixture. This is the cross-process mechanism for the
40
- * `captureNetwork` option reporter constructor options are not propagated to
41
- * the fixture because they run in different Playwright worker processes.
39
+ * capture in the fixture. The reporter bridges the `captureNetwork` option to
40
+ * this env var at startup (when not already set), so the fixture receives it.
41
+ * An explicit env var always wins over the reporter option.
42
42
  */
43
43
  export declare function resolveOptions(opts?: TraceLaneOptions, env?: EnvLike): ResolvedOptions;
44
44
  export {};
package/dist/options.js CHANGED
@@ -21,9 +21,9 @@ function defaultEnv() {
21
21
  * invalid `TRACELANE_MODE` is ignored. `env` is injectable for testing.
22
22
  *
23
23
  * `TRACELANE_CAPTURE_NETWORK=false` (case-insensitive) disables CDP network
24
- * capture in the fixture. This is the cross-process mechanism for the
25
- * `captureNetwork` option reporter constructor options are not propagated to
26
- * the fixture because they run in different Playwright worker processes.
24
+ * capture in the fixture. The reporter bridges the `captureNetwork` option to
25
+ * this env var at startup (when not already set), so the fixture receives it.
26
+ * An explicit env var always wins over the reporter option.
27
27
  */
28
28
  export function resolveOptions(opts = {}, env = defaultEnv()) {
29
29
  const mode = isMode(env.TRACELANE_MODE) ? env.TRACELANE_MODE : (opts.mode ?? 'failed');
@@ -1,5 +1,4 @@
1
- import type { CDPSession, Page } from '@playwright/test';
2
- import type { TestInfo } from '@playwright/test';
1
+ import type { CDPSession, Frame, Page, TestInfo } from '@playwright/test';
3
2
  import { type Recorder } from '@tracelane/core';
4
3
  import type { ResolvedOptions } from './options.js';
5
4
  /** Inputs to start a capture session. */
@@ -17,6 +16,12 @@ export interface StartedSession {
17
16
  browserName?: string;
18
17
  /** Browser version for the report header, when resolvable. */
19
18
  browserVersion?: string;
19
+ /** The page we attached the navigation listener to (for removal at finalize). */
20
+ page?: Page;
21
+ /** The framenavigated handler, removed in runFinalize to avoid cross-test leaks. */
22
+ onNav?: (frame: Frame) => void;
23
+ /** Set when capture could not start (e.g. CSP); runFinalize writes nothing. */
24
+ disabled?: boolean;
20
25
  }
21
26
  /** Inputs to finalize a session (report build/write). */
22
27
  export interface FinalizeInput {
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-session.d.ts","sourceRoot":"","sources":["../src/playwright-session.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAwC,MAAM,iBAAiB,CAAC;AAEtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,oFAAoF;IACpF,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAWD,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,sFAAsF;AACtF,wBAAsB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAA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AAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,sFAAsF;AACtF,wBAAsB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAoFzE;AAoBD,qFAAqF;AACrF,wBAAsB,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B9F;AAED,mFAAmF;AACnF,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,IAAI,CAAC,CAOf"}
@@ -38,47 +38,70 @@ export async function runStart(input) {
38
38
  catch {
39
39
  browserVersion = undefined;
40
40
  }
41
- // CDP network capture is Chromium-only (P1 PRD §E.2). When opted in and the
42
- // browser is Chromium, open a CDP session and attach the shared capture path;
43
- // on Firefox/WebKit (no CDP) we silently degrade to rrweb + console.
41
+ // CDP network capture is Chromium-only (P1 PRD §E.2). Open CDP only when opted
42
+ // in and on Chromium; on Firefox/WebKit (no CDP) we silently degrade to rrweb +
43
+ // console. A failure opening CDP here also degrades to rrweb+console only.
44
44
  let cdp;
45
45
  if (options.captureNetwork && browserName === 'chromium') {
46
- cdp = await context.newCDPSession(page);
46
+ try {
47
+ cdp = await context.newCDPSession(page);
48
+ }
49
+ catch {
50
+ cdp = undefined; // no CDP; rrweb+console still work
51
+ console.warn('[tracelane] could not open a CDP session; network capture unavailable, degrading to rrweb+console only.');
52
+ }
47
53
  }
48
- // Once the CDP session is open it is ours to close. If anything after this
49
- // point throws (attachNetworkCapture / recorder.start()), runStart never
50
- // returns so runFinalize, the only other detach site, never runs and the
51
- // session would leak for the worker's lifetime. Detach here before rethrowing.
52
- try {
53
- if (cdp) {
54
- await attachNetworkCapture(createPlaywrightExecutor(page, cdp));
54
+ // ONE executor for both network capture and the recorder (recorder uses only
55
+ // execute(); cdp/on are used solely by attachNetworkCapture).
56
+ const executor = createPlaywrightExecutor(page, cdp);
57
+ // Network capture is best-effort: if it fails, detach CDP and continue.
58
+ if (cdp) {
59
+ try {
60
+ await attachNetworkCapture(executor);
55
61
  }
56
- const executor = createPlaywrightExecutor(page, cdp);
57
- const recorder = createRecorder({
58
- executor,
59
- rrwebBundle,
60
- mode: options.mode,
61
- // MVP: in-page network plugin off; the CDP path above is the network
62
- // channel. The recorder still captures rrweb + console on all browsers.
63
- });
62
+ catch {
63
+ await cdp.detach().catch(() => { });
64
+ cdp = undefined;
65
+ console.warn('[tracelane] network capture unavailable (CDP); degrading to rrweb+console only.');
66
+ }
67
+ }
68
+ const recorder = createRecorder({
69
+ executor,
70
+ rrwebBundle,
71
+ mode: options.mode,
72
+ // MVP: in-page network plugin off; the CDP path above is the network
73
+ // channel. The recorder still captures rrweb + console on all browsers.
74
+ });
75
+ // Capture start is best-effort: a CSP / injection failure must NOT fail the
76
+ // user's test. Degrade to a disabled session that writes no report.
77
+ try {
64
78
  await recorder.start();
65
- const session = { recorder };
66
- if (cdp)
67
- session.cdp = cdp;
68
- if (browserName !== undefined)
69
- session.browserName = browserName;
70
- if (browserVersion !== undefined)
71
- session.browserVersion = browserVersion;
72
- return session;
73
79
  }
74
80
  catch (err) {
75
- if (cdp) {
76
- await cdp.detach().catch(() => {
77
- /* page/context may already be closed */
78
- });
79
- }
80
- throw err;
81
+ if (cdp)
82
+ await cdp.detach().catch(() => { });
83
+ console.warn('[tracelane] capture unavailable on this page (likely a Content-Security-Policy blocking ' +
84
+ "script evaluation; rrweb needs 'unsafe-eval'). The test runs normally; no replay was recorded.", err);
85
+ return { recorder, disabled: true };
81
86
  }
87
+ const onNav = (frame) => {
88
+ if (frame !== page.mainFrame())
89
+ return; // main frame only; ignore sub-frames
90
+ // Fire-and-forget: navigation may tear the page down; the recorder's
91
+ // cooldown + monotonic session id dedupe hash/HMR re-renders.
92
+ void recorder.reinject(frame.url()).catch(() => {
93
+ /* best-effort; page may be gone */
94
+ });
95
+ };
96
+ page.on('framenavigated', onNav);
97
+ const session = { recorder, page, onNav };
98
+ if (cdp)
99
+ session.cdp = cdp;
100
+ if (browserName !== undefined)
101
+ session.browserName = browserName;
102
+ if (browserVersion !== undefined)
103
+ session.browserVersion = browserVersion;
104
+ return session;
82
105
  }
83
106
  /** Compose the report metadata from Playwright's testInfo + resolved browser info. */
84
107
  function buildMeta(testInfo, session) {
@@ -104,6 +127,14 @@ function buildMeta(testInfo, session) {
104
127
  }
105
128
  /** Finalize the recorder (apply mode policy), and write a report when one is due. */
106
129
  export async function runFinalize(session, input) {
130
+ if (session.disabled)
131
+ return; // capture never started; nothing to finalize/clean up
132
+ // Unsubscribe the navigation listener BEFORE the first await: finalize() returns
133
+ // the live event buffer, so a late main-frame navigation during teardown could
134
+ // reinject and leak a stray tracelane.nav event into the report being written.
135
+ if (session.page && session.onNav) {
136
+ session.page.off('framenavigated', session.onNav);
137
+ }
107
138
  const { testInfo, options } = input;
108
139
  try {
109
140
  const { shouldBuildReport, events } = await session.recorder.finalize({
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-session.js","sourceRoot":"","sources":["../src/playwright-session.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,EAAE;AACF,0EAA0E;AAC1E,sEAAsE;AACtE,+EAA+E;AAC/E,6EAA6E;AAC7E,wCAAwC;AAIxC,OAAO,EAAiB,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAmB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAoBzD,iFAAiF;AACjF,SAAS,aAAa,CAAC,IAAU;IAC/B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,O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CAAC,iBAAiB;YAAE,OAAO;QAC/B,WAAW,CAAC;YACV,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,0EAA0E;YAC1E,qCAAqC;YACrC,GAAG,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI;YAC3B,MAAM;YACN,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;SACnC,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,kEAAkE;QAClE,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBACpC,wCAAwC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAA8C;IAE9C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC;QAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC,CAAC;IACH,MAAM,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -3,16 +3,16 @@ import { type TraceLaneOptions } from './options.js';
3
3
  /**
4
4
  * tracelane's Playwright reporter. Pair it with the fixture
5
5
  * (`import { test } from '@tracelane/playwright/fixture'`) — the fixture records
6
- * + writes reports; this reporter validates config at startup.
6
+ * + writes reports; this reporter validates config at startup and bridges options
7
+ * to the fixture via TRACELANE_* env vars.
7
8
  */
8
9
  export declare class TraceLaneReporter implements Reporter {
9
- private failed;
10
10
  constructor(opts?: TraceLaneOptions);
11
11
  /** The fixture + Playwright own the run output; this reporter is silent. */
12
12
  printsToStdio(): boolean;
13
13
  onBegin(_config: FullConfig, _suite: Suite): void;
14
14
  onTestBegin(_test: TestCase, _result: TestResult): void;
15
- onTestEnd(test: TestCase, _result: TestResult): void;
15
+ onTestEnd(_test: TestCase, _result: TestResult): void;
16
16
  onEnd(_result: FullResult): void;
17
17
  }
18
18
  export default TraceLaneReporter;
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,cAAc,CAAC;AAErE;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,QAAQ;IAChD,OAAO,CAAC,MAAM,CAAK;gBAEP,IAAI,GAAE,gBAAqB;IAiBvC,4EAA4E;IAC5E,aAAa,IAAI,OAAO;IAIxB,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI;IAIjD,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAIvD,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAOpD,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;CAKjC;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,cAAc,CAAC;AAErE;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,QAAQ;gBACpC,IAAI,GAAE,gBAAqB;IA8BvC,4EAA4E;IAC5E,aAAa,IAAI,OAAO;IAIxB,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI;IAIjD,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAIvD,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAKrD,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;CAKjC;AAED,eAAe,iBAAiB,CAAC"}
package/dist/reporter.js CHANGED
@@ -3,35 +3,39 @@
3
3
  //
4
4
  // IMPORTANT: the Reporter does NOT build reports — the per-test HTML build lives
5
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.
6
+ // By design the Reporter never touches `page`. Its two jobs are:
7
+ // 1. Config validation: resolveOptions in the constructor so invalid config
8
+ // surfaces early (before any test runs).
9
+ // 2. Options→env bridge: reporter constructor options are bridged to the
10
+ // fixture via TRACELANE_* env vars (set only when unset, so explicit env
11
+ // still wins). The fixture runs in separate Playwright worker processes and
12
+ // reads env vars to pick up the reporter's config. Verified: env set here
13
+ // (config load, main process) is inherited by workers spawned after.
9
14
  //
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
+ // The reporter does NOT tally pass/fail counts and does NOT print any
16
+ // end-of-run summary. All per-test reporting is handled by the fixture.
15
17
  import { resolveOptions } from './options.js';
16
18
  /**
17
19
  * tracelane's Playwright reporter. Pair it with the fixture
18
20
  * (`import { test } from '@tracelane/playwright/fixture'`) — the fixture records
19
- * + writes reports; this reporter validates config at startup.
21
+ * + writes reports; this reporter validates config at startup and bridges options
22
+ * to the fixture via TRACELANE_* env vars.
20
23
  */
21
24
  export class TraceLaneReporter {
22
- failed = 0;
23
25
  constructor(opts = {}) {
24
- // Resolve up front so an invalid config surfaces early (throws on bad input).
26
+ // Validate up front so an invalid config surfaces early.
25
27
  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.');
28
+ const env = globalThis.process?.env;
29
+ if (env !== undefined) {
30
+ if (opts.mode !== undefined && env.TRACELANE_MODE === undefined) {
31
+ env.TRACELANE_MODE = opts.mode;
32
+ }
33
+ if (opts.outDir !== undefined && env.TRACELANE_OUT_DIR === undefined) {
34
+ env.TRACELANE_OUT_DIR = opts.outDir;
35
+ }
36
+ if (opts.captureNetwork !== undefined && env.TRACELANE_CAPTURE_NETWORK === undefined) {
37
+ env.TRACELANE_CAPTURE_NETWORK = String(opts.captureNetwork);
38
+ }
35
39
  }
36
40
  }
37
41
  /** The fixture + Playwright own the run output; this reporter is silent. */
@@ -39,17 +43,14 @@ export class TraceLaneReporter {
39
43
  return false;
40
44
  }
41
45
  onBegin(_config, _suite) {
42
- this.failed = 0;
46
+ // No-op: validation and env bridging are done in the constructor.
43
47
  }
44
48
  onTestBegin(_test, _result) {
45
49
  // No-op: the fixture starts the recorder per test.
46
50
  }
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++;
51
+ onTestEnd(_test, _result) {
52
+ // No-op: the fixture owns per-test report building; this reporter does not
53
+ // tally pass/fail counts.
53
54
  }
54
55
  onEnd(_result) {
55
56
  // No-op: output removed (printsToStdio() is false; console.log here would
@@ -1 +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;C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AAkE;IACpE,CAAC;IAED,WAAW,CAAC,KAAe,EAAE,OAAmB;QAC9C,mDAAmD;IACrD,CAAC;IAED,SAAS,CAAC,KAAe,EAAE,OAAmB;QAC5C,2EAA2E;QAC3E,0BAA0B;IAC5B,CAAC;IAED,KAAK,CAAC,OAAmB;QACvB,0EAA0E;QAC1E,2EAA2E;QAC3E,8BAA8B;IAChC,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracelane/playwright",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "Playwright reporter + auto-fixture that writes a self-contained replayable HTML report on test failure (rrweb + console + failed-network). No SaaS.",
5
5
  "keywords": [
6
6
  "tracelane",
@@ -40,24 +40,18 @@
40
40
  "NOTICE",
41
41
  "README.md"
42
42
  ],
43
- "scripts": {
44
- "build": "tsc -p tsconfig.json && node scripts/build-rrweb-bundle.mjs",
45
- "typecheck": "tsc -p tsconfig.json --noEmit",
46
- "test": "vitest run --passWithNoTests",
47
- "test:e2e": "node scripts/build-rrweb-bundle.mjs && node ./e2e/run.mjs"
48
- },
49
43
  "dependencies": {
50
- "@tracelane/core": "workspace:*",
51
- "@tracelane/report": "workspace:*"
44
+ "@tracelane/report": "0.1.0-alpha.14",
45
+ "@tracelane/core": "0.1.0-alpha.12"
52
46
  },
53
47
  "peerDependencies": {
54
48
  "@playwright/test": ">=1.40.0"
55
49
  },
56
50
  "devDependencies": {
57
- "@cubenest/rrweb-core": "workspace:*",
58
51
  "@playwright/test": "^1.60.0",
59
52
  "esbuild": "^0.28.0",
60
- "tsx": "^4.19.0"
53
+ "tsx": "^4.19.0",
54
+ "@cubenest/rrweb-core": "0.1.0-alpha.5"
61
55
  },
62
56
  "publishConfig": {
63
57
  "access": "public",
@@ -74,5 +68,11 @@
74
68
  "homepage": "https://tracelane.cubenest.in",
75
69
  "engines": {
76
70
  "node": ">=20.18.0"
71
+ },
72
+ "scripts": {
73
+ "build": "tsc -p tsconfig.json && node scripts/build-rrweb-bundle.mjs",
74
+ "typecheck": "tsc -p tsconfig.json --noEmit",
75
+ "test": "vitest run --passWithNoTests",
76
+ "test:e2e": "node scripts/build-rrweb-bundle.mjs && node ./e2e/run.mjs"
77
77
  }
78
- }
78
+ }