Running Tests Locally
Overlay Documentation
This page covers writing tests within rhdh-plugin-export-overlays. For using rhdh-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
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 "rhdh-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.zipEnvironment Variables
Using .env File
Create .env for local configuration:
# .env
RHDH_VERSION=1.5
INSTALLATION_METHOD=helm
SKIP_KEYCLOAK_DEPLOYMENT=false2
3
4
Common Variables
| Variable | Description | Default |
|---|---|---|
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 --noEmitLinting
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