Running Tests Locally
Overlay Documentation
This page covers writing tests within rhdh-plugin-export-overlays. For using @red-hat-developer-hub/e2e-test-utils in external projects, see the Guide.
This tutorial covers the local development workflow for overlay E2E tests.
Prerequisites
Before running tests locally, ensure you have:
- Node.js 22+ installed
- Yarn 3+ installed
- Access to an OpenShift cluster
- CLI tools:
oc,kubectl,helm - Logged into the cluster:
oc login <cluster-url>
Setup
1. Navigate to Test Directory
cd workspaces/<plugin>/e2e-tests2. Install Dependencies
yarn install3. Install Playwright Browsers
npx playwright installRunning Tests
Multi-Workspace Testing
To run tests across multiple workspaces simultaneously, use the run-e2e.sh unified test runner instead of individual workspace commands:
# Run all workspaces
./run-e2e.sh
# Run specific workspaces
./run-e2e.sh -w tech-radar -w keycloak
# Use local e2e-test-utils build
E2E_TEST_UTILS_PATH=/path/to/rhdh-e2e-test-utils ./run-e2e.sh -w tech-radar2
3
4
5
6
7
8
Run All Tests
yarn testRun in Headed Mode
See the browser while tests run:
yarn test:headedRun with Playwright UI
Interactive test runner:
yarn test:uiRun Specific Test File
yarn test tests/specs/my-plugin.spec.tsRun Specific Test
yarn test -g "test name pattern"Viewing Results
View HTML Report
After tests complete:
yarn reportReport Location
Reports are saved to playwright-report/:
playwright-report/index.html- HTML report- Test artifacts (screenshots, videos, traces)
Development Workflow
1. Write Test
Create or modify tests/specs/<plugin>.spec.ts:
import { test, expect } from "@red-hat-developer-hub/e2e-test-utils/test";
test.describe("Test <plugin>", () => {
test.beforeAll(async ({ rhdh }) => {
await rhdh.configure({ auth: "keycloak" });
await rhdh.deploy();
});
test.beforeEach(async ({ loginHelper }) => {
await loginHelper.loginAsKeycloakUser();
});
test("new test case", async ({ uiHelper }) => {
// Your test code
});
});2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2. Run Test
yarn test:headed3. Debug Failures
Use Playwright UI for debugging:
yarn test:ui4. View Trace
For failed tests, traces are automatically captured:
npx playwright show-trace playwright-report/trace.zipTest local changes to e2e-test-utils in Overlays
If you want to try your local changes to @red-hat-developer-hub/e2e-test-utils work for Overlays:
- Build the utils package:
cd /Your/Path/Projects/rhdh-e2e-test-utils
yarn build2
- Point the Overlays workspace
e2e-test-utilsdependency to your local checkout:
cd /Your/Path/Projects/rhdh-plugin-export-overlays/workspaces/<plugin>/e2e-testsUpdate package.json:
{
"dependencies": {
"@red-hat-developer-hub/e2e-test-utils": "file:/Your/Path/Projects/rhdh-e2e-test-utils"
}
}2
3
4
5
- Reinstall dependencies and run tests:
yarn install
yarn test:headed2
When you change the utils package again, re-run yarn build in rhdh-e2e-test-utils, then run yarn install again in the overlay e2e-tests workspace.
Troubleshooting local linking
If you see odd module-resolution issues while testing a locally linked e2e-test-utils package, try running the Overlays tests with:
NODE_PRESERVE_SYMLINKS=1 yarn test:headedSecrets from Vault
Instead of manually copying secrets from the Vault UI into .env files, you can fetch them automatically by setting VAULT=1:
# From workspace
cd workspaces/argocd/e2e-tests
yarn test:vault
# Or equivalently
VAULT=1 yarn test
# From repo root
VAULT=1 ./run-e2e.sh -w argocd2
3
4
5
6
7
8
9
This will:
- Check that the
vaultCLI is installed - Log you in via OIDC if needed (opens a browser)
- Fetch global secrets and all per-workspace secrets from Vault
- Inject
VAULT_*keys intoprocess.envfor the test run
TIP
If you don't have Vault access, request it in Slack: #rhdh-e2e-tests.
Prerequisites: Install the Vault CLI.
You can also override the Vault server or base path:
VAULT=1 VAULT_ADDR=https://my-vault.example.com VAULT_BASE_PATH=my/path yarn testEnvironment Variables
Using .env File
Create .env for local configuration (alternative to Vault):
# .env
RHDH_VERSION=1.5
INSTALLATION_METHOD=helm
SKIP_KEYCLOAK_DEPLOYMENT=false
# Secrets (or use VAULT=1 instead)
VAULT_GITHUB_TOKEN=ghp_xxx2
3
4
5
6
7
Common Variables
| Variable | Description | Default |
|---|---|---|
VAULT | Fetch secrets from Vault automatically (1 or true) | - |
RHDH_VERSION | RHDH version to deploy | next (latest) |
INSTALLATION_METHOD | helm or operator | helm |
SKIP_KEYCLOAK_DEPLOYMENT | Skip Keycloak deployment entirely (for guest auth) | false |
See Environment Variables Reference for all available variables.
Skipping Keycloak Deployment
Use this when running tests with guest authentication (no Keycloak needed):
SKIP_KEYCLOAK_DEPLOYMENT=true yarn testTIP
You don't need this flag if Keycloak already exists in the cluster. By default, the test framework will detect and reuse an existing Keycloak instance.
Running Against Existing Cluster
If RHDH is already deployed and you want to test against it:
test.beforeAll(async ({ rhdh }) => {
// Skip deployment, just use existing instance
// Set baseURL manually if needed
});
test.beforeEach(async ({ page }) => {
await page.goto("https://existing-rhdh-url.com");
// Login manually or use existing session
});2
3
4
5
6
7
8
9
Code Quality Checks
Type Checking
yarn tsc:checkLinting
yarn lint:check
yarn lint:fix # Auto-fix issues2
Formatting
yarn prettier:check
yarn prettier:fix # Auto-format2
All Checks
yarn checkDebugging Tips
1. Use Headed Mode
yarn test:headed2. Slow Down Execution
Add slowMo to config:
// playwright.config.ts
export default defineConfig({
use: {
launchOptions: {
slowMo: 500, // 500ms delay between actions
},
},
});2
3
4
5
6
7
8
3. Take Screenshots
test("screenshot test", async ({ page }) => {
await page.goto("/");
await page.screenshot({ path: "debug.png" });
});2
3
4
4. View Console Logs
test("console test", async ({ page }) => {
page.on("console", (msg) => console.log(msg.text()));
await page.goto("/");
});2
3
4
Cleanup
Auto-Cleanup in CI
Automatic Namespace Cleanup
In CI environments (when CI=true), namespaces are automatically deleted after tests complete. This prevents resource accumulation on shared clusters.
For local development, namespaces are preserved for debugging. You must clean them up manually.
Delete Test Namespace
After testing locally, clean up the namespace:
oc delete namespace <test-namespace>The namespace name is derived from the project name in playwright.config.ts.
Clean Up Playwright Artifacts
rm -rf playwright-report test-resultsRelated Pages
- CI/CD Pipeline - Automated testing
- Troubleshooting - Common issues
- Directory Layout - File structure