@neon-pixels/playwright-preset 0.3.0 → 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.
package/README.md CHANGED
@@ -45,6 +45,32 @@ export default defineConfig({
45
45
 
46
46
  The config reuses a running server locally, always starts a fresh one when `CI` is set, retries failed tests twice in CI, and records a trace on the first retry.
47
47
 
48
+ ### Overriding the web server and base URL
49
+
50
+ Both `createPlaywrightConfig` and `createClerkPlaywrightConfig` return a config where `webServer` is a single object and `use` is always defined, so you can spread either one to change a single key without restating the rest:
51
+
52
+ ```ts
53
+ const base = createPlaywrightConfig({
54
+ command: "pnpm dev --port 3000",
55
+ port: 3000,
56
+ });
57
+
58
+ export default defineConfig({
59
+ ...base,
60
+ webServer: { ...base.webServer, reuseExistingServer: false },
61
+ });
62
+ ```
63
+
64
+ The web server `url` and `baseURL` are always `http://localhost:<port>`. If your server binds only `127.0.0.1` and does not answer on `localhost`, override both so Playwright waits on, and browses to, the same address:
65
+
66
+ ```ts
67
+ export default defineConfig({
68
+ ...base,
69
+ use: { ...base.use, baseURL: "http://127.0.0.1:3000" },
70
+ webServer: { ...base.webServer, url: "http://127.0.0.1:3000" },
71
+ });
72
+ ```
73
+
48
74
  ### Clerk
49
75
 
50
76
  ```ts
@@ -76,7 +102,7 @@ The config adds a `setup` project that runs any file ending in `auth.setup.ts`.
76
102
 
77
103
  Building the config also copies `NUXT_CLERK_SECRET_KEY` and `NUXT_PUBLIC_CLERK_PUBLISHABLE_KEY` onto the `CLERK_SECRET_KEY` and `CLERK_PUBLISHABLE_KEY` names that `@clerk/testing` reads, without overwriting values already set. `clerkSetup()` runs inside the setup test rather than in `globalSetup`, so the testing token is not inherited by your web server, where it would sign in every request.
78
104
 
79
- To change anything, override it in your own config: spread the result and replace the key.
105
+ To change anything, override it in your own config: spread the result and replace the key. See [Overriding the web server and base URL](#overriding-the-web-server-and-base-url).
80
106
 
81
107
  ### Consent
82
108
 
package/clerk.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import type { Page, PlaywrightTestConfig } from "@playwright/test";
2
- import type { PlaywrightPresetOptions } from "./index.js";
1
+ import type { Page } from "@playwright/test";
2
+ import type {
3
+ PlaywrightPresetConfig,
4
+ PlaywrightPresetOptions,
5
+ } from "./index.js";
3
6
 
4
7
  /** Where the setup project writes the signed-in browser state. */
5
8
  export declare const AUTH_STATE_FILE: string;
@@ -38,7 +41,7 @@ export declare function applyClerkEnvironment(
38
41
 
39
42
  export declare function createClerkPlaywrightConfig(
40
43
  options: PlaywrightPresetOptions,
41
- ): PlaywrightTestConfig;
44
+ ): PlaywrightPresetConfig;
42
45
 
43
46
  /** Registers the "authenticate" setup test. Call it from `e2e/auth.setup.ts`. */
44
47
  export declare function defineClerkAuthSetup(
package/index.d.ts CHANGED
@@ -9,6 +9,24 @@ export interface PlaywrightPresetOptions {
9
9
  env?: Record<string, string>;
10
10
  }
11
11
 
12
+ /** A single web server config object (never the array form). */
13
+ export type PlaywrightPresetWebServer = Exclude<
14
+ NonNullable<PlaywrightTestConfig["webServer"]>,
15
+ unknown[]
16
+ >;
17
+
18
+ /**
19
+ * The preset's config. `webServer` is one object and `use` is defined, so
20
+ * `{ ...base.webServer, reuseExistingServer: false }` typechecks.
21
+ */
22
+ export type PlaywrightPresetConfig = Omit<
23
+ PlaywrightTestConfig,
24
+ "use" | "webServer"
25
+ > & {
26
+ use: NonNullable<PlaywrightTestConfig["use"]>;
27
+ webServer: PlaywrightPresetWebServer;
28
+ };
29
+
12
30
  export declare function createPlaywrightConfig(
13
31
  options: PlaywrightPresetOptions,
14
- ): PlaywrightTestConfig;
32
+ ): PlaywrightPresetConfig;
package/index.js CHANGED
@@ -28,7 +28,7 @@ function assertValidCommand(command) {
28
28
 
29
29
  /**
30
30
  * @param {import("./index.js").PlaywrightPresetOptions} options
31
- * @returns {import("@playwright/test").PlaywrightTestConfig}
31
+ * @returns {import("./index.js").PlaywrightPresetConfig}
32
32
  */
33
33
  export function createPlaywrightConfig(options) {
34
34
  const { command, port, env } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon-pixels/playwright-preset",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Shared Playwright configuration for Neon Pixels projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@clerk/testing": "^2.0.0",
43
- "@neon-pixels/consent": "^0.3.0",
43
+ "@neon-pixels/consent": "^0.5.0",
44
44
  "@playwright/test": "^1.50.0"
45
45
  },
46
46
  "peerDependenciesMeta": {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@clerk/testing": "^2.3.6",
56
- "@neon-pixels/consent": "0.3.0",
56
+ "@neon-pixels/consent": "0.5.0",
57
57
  "@playwright/test": "^1.65.1"
58
58
  },
59
59
  "scripts": {