You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `key`parameter must be unique across all `runOnce` calls in your test run. Use a descriptive name that reflects the operation:
254
+
The `key` must be globally unique across **all spec files and projects** in the same Playwright run. If two `runOnce` calls in different files use the same key, only the first one will execute. Use a prefix that includes the workspace or project name:
Copy file name to clipboardExpand all lines: docs/overlay/tutorials/custom-deployment.md
+71-57Lines changed: 71 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,26 +18,32 @@ Your plugin tests may require pre-requisites when:
18
18
19
19
## The Pattern
20
20
21
-
Deploy pre-requisites **after**`rhdh.configure()` but **before**`rhdh.deploy()`:
21
+
Deploy pre-requisites **after**`rhdh.configure()` but **before**`rhdh.deploy()`. Since these operations are expensive and create persistent cluster resources, wrap the entire block in `test.runOnce` to prevent re-execution on worker restarts:
// 2. Deploy pre-requisite service (see examples below)
31
-
// ...
31
+
// 2. Deploy pre-requisite service (see examples below)
32
+
// ...
32
33
33
-
// 3. Set environment variable if needed for RHDH config
34
-
process.env.MY_SERVICE_URL="...";
34
+
// 3. Set environment variable if needed for RHDH config
35
+
process.env.MY_SERVICE_URL="...";
35
36
36
-
// 4. Deploy RHDH (uses the environment variable)
37
-
awaitrhdh.deploy();
37
+
// 4. Deploy RHDH (uses the environment variable)
38
+
awaitrhdh.deploy();
39
+
});
38
40
});
39
41
```
40
42
43
+
::: tip When is `test.runOnce` needed?
44
+
`rhdh.deploy()` already skips automatically on worker restarts. But the pre-deploy steps (deploying external services, running scripts) don't have this protection. `test.runOnce` ensures the **entire setup** runs only once. The `key` must be **globally unique** across all spec files and projects in the same Playwright run — prefix it with your workspace name (e.g., `"tech-radar-setup"`). See [`test.runOnce`](/guide/core-concepts/playwright-fixtures#test-runonce-—-run-any-expensive-operation-once) for details.
45
+
:::
46
+
41
47
## Examples
42
48
43
49
### Using TypeScript / k8sClient
@@ -48,26 +54,28 @@ You can deploy pre-requisites directly in TypeScript using the Kubernetes client
48
54
import { test } from"@red-hat-developer-hub/e2e-test-utils/test";
0 commit comments