plum-e2e 2.9.2 → 2.9.4

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.
@@ -87,13 +87,18 @@ function attachRecorder(pg: Page): void {
87
87
  });
88
88
  }
89
89
 
90
- export async function setup(): Promise<void> {
90
+ // contextOptions is passed straight to Browser.newContext() use it for
91
+ // project-specific needs (viewport, permissions, etc.) rather than creating
92
+ // a second context yourself, so rrweb recording (wired below) still covers it.
93
+ export async function setup(
94
+ contextOptions: Parameters<Browser['newContext']>[0] = {}
95
+ ): Promise<void> {
91
96
  const isHeadless = process.env.IS_HEADLESS?.toLowerCase() !== 'false';
92
97
  const browserName = (process.env.BROWSER || 'chromium').toLowerCase();
93
98
  const browserType =
94
99
  browserName === 'firefox' ? firefox : browserName === 'webkit' ? webkit : chromium;
95
100
  _browser = await browserType.launch({ headless: isHeadless });
96
- _context = await _browser.newContext();
101
+ _context = await _browser.newContext(contextOptions);
97
102
 
98
103
  _tabs = new Map();
99
104
  _tabCounter = 0;
@@ -259,10 +264,25 @@ function resolveStepKeyword(gherkinDocument: any, pickleStep: any): string {
259
264
  return steps.find((s) => s.id === astNodeId)?.keyword?.trim() ?? '';
260
265
  }
261
266
 
267
+ /**
268
+ * "Given/When/Then <step text>" for a BeforeStep's (pickleStep, gherkinDocument)
269
+ * pair — pass straight to markStepStart(). Exported for a project that writes
270
+ * its own BeforeStep instead of using registerHooks(), so it doesn't need to
271
+ * duplicate the keyword-recovery logic to get the same replay labels.
272
+ */
273
+ export function stepLabel(gherkinDocument: any, pickleStep: any): string {
274
+ const keyword = resolveStepKeyword(gherkinDocument, pickleStep);
275
+ const text = pickleStep?.text ?? '';
276
+ return keyword ? `${keyword} ${text}` : text;
277
+ }
278
+
262
279
  /**
263
280
  * Registers Plum's own Before/BeforeStep/After hooks. Call once from your
264
281
  * own tests/utils/hooks.ts — Cucumber supports multiple Before/After hooks,
265
- * so your own hooks can still be added alongside this.
282
+ * so your own hooks can still be added alongside this. If you need custom
283
+ * context options (viewport, permissions, etc.) or to run something between
284
+ * browser launch and the first page load, call setup()/markStepStart()/
285
+ * flushRecordings()/teardown() from your own hooks instead of this.
266
286
  */
267
287
  export function registerHooks(): void {
268
288
  Before(async ({ pickle }: ITestCaseHookParameter) => {
@@ -278,9 +298,7 @@ export function registerHooks(): void {
278
298
  pickleStep: any;
279
299
  gherkinDocument: any;
280
300
  }) {
281
- const keyword = resolveStepKeyword(gherkinDocument, pickleStep);
282
- const text = pickleStep?.text ?? '';
283
- await markStepStart(keyword ? `${keyword} ${text}` : text);
301
+ await markStepStart(stepLabel(gherkinDocument, pickleStep));
284
302
  });
285
303
 
286
304
  After(async function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plum-e2e",
3
- "version": "2.9.2",
3
+ "version": "2.9.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/silverlunah/plum.git"