@scenarist/playwright-helpers 0.4.15 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +13 -8
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -230,7 +230,7 @@ test("premium user scenario", async ({ page }) => {
230
230
  });
231
231
  ```
232
232
 
233
- > **Note on testing**: This package has comprehensive behavior-driven tests at the package level. This is NOT unit testing - we test observable behavior through the public API only. See [Testing Philosophy](#testing-philosophy) below for full rationale.
233
+ > **Note on testing**: This package has comprehensive behavior-driven tests at the package level. This is NOT unit testing - we test observable behavior through the public API only.
234
234
 
235
235
  #### Options
236
236
 
@@ -238,8 +238,7 @@ test("premium user scenario", async ({ page }) => {
238
238
  type SwitchScenarioOptions = {
239
239
  readonly baseURL: string; // Base URL of your application
240
240
  readonly endpoint?: string; // Scenario endpoint path or absolute URL (default: '/__scenario__')
241
- readonly testIdHeader?: string; // Test ID header name (default: 'x-scenarist-test-id')
242
- readonly variant?: string; // Optional scenario variant
241
+ readonly testId?: string; // Test ID to use (default: auto-generated)
243
242
  };
244
243
  ```
245
244
 
@@ -249,10 +248,10 @@ type SwitchScenarioOptions = {
249
248
 
250
249
  The `switchScenario` helper:
251
250
 
252
- 1. Generates a unique test ID (`test-{scenarioId}-{timestamp}`)
253
- 2. POSTs to the scenario endpoint with the test ID header
254
- 3. Verifies the scenario switch succeeded (200 response)
255
- 4. Sets the test ID header for all subsequent requests in the test
251
+ 1. Generates a unique test ID (`test-{scenarioId}-{uuid}`)
252
+ 2. Sets the test ID header for all subsequent requests in the test
253
+ 3. POSTs to the scenario endpoint with the test ID header
254
+ 4. Verifies the scenario switch succeeded (200 response)
256
255
 
257
256
  This reduces scenario switching from 9 lines of boilerplate to 2 lines:
258
257
 
@@ -451,9 +450,15 @@ The debug fixtures require a debug state endpoint in your application. Create it
451
450
 
452
451
  ```typescript
453
452
  // pages/api/__scenarist__/state.ts
453
+ import type { NextApiRequest, NextApiResponse } from "next";
454
454
  import { scenarist } from "@/lib/scenarist";
455
455
 
456
- export default scenarist?.createStateEndpoint();
456
+ // In production, scenarist is undefined due to conditional exports.
457
+ // Next.js requires a default export function, so fall back to a 405 handler.
458
+ export default scenarist?.createStateEndpoint() ??
459
+ ((_req: NextApiRequest, res: NextApiResponse) => {
460
+ res.status(405).end();
461
+ });
457
462
  ```
458
463
 
459
464
  **App Router:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scenarist/playwright-helpers",
3
- "version": "0.4.15",
3
+ "version": "0.5.0",
4
4
  "description": "Playwright test helpers for Scenarist scenario management",
5
5
  "author": "Paul Hammond (citypaul) <paul@packsoftware.co.uk>",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "LICENSE"
44
44
  ],
45
45
  "dependencies": {
46
- "@scenarist/core": "0.4.15"
46
+ "@scenarist/core": "0.5.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@playwright/test": "^1.0.0"