Your First Test
Create your first E2E test for RHDH using rhdh-e2e-test-utils.
Quick Start Available
For a faster setup, see the Quick Start Guide. This tutorial provides more detailed explanations for each step.
Prerequisites
- Node.js >= 22
- Yarn >= 3
- OpenShift cluster access
oc,kubectl,helminstalled
Before continuing, complete the project scaffolding in Quick Start. This tutorial focuses on why each step matters and how to debug effectively.
Step 1: Write Your Test
tests/specs/first-test.spec.ts:
typescript
import { test, expect } from "rhdh-e2e-test-utils/test";
test.describe("My First Test Suite", () => {
test.beforeAll(async ({ rhdh }) => {
// Use guest auth for simplicity
await rhdh.configure({ auth: "guest" });
await rhdh.deploy();
});
test.beforeEach(async ({ page, loginHelper }) => {
await page.goto("/");
await loginHelper.loginAsGuest();
});
test("should display RHDH home page", async ({ uiHelper }) => {
await uiHelper.verifyHeading(/Red Hat Developer Hub|RHDH/);
});
test("should navigate to catalog", async ({ page, uiHelper }) => {
await uiHelper.openSidebar("Catalog");
await expect(page).toHaveURL(/.*catalog/);
await uiHelper.verifyHeading("Catalog");
});
});Step 2: Login to OpenShift
bash
oc login --server=https://api.your-cluster.com:6443 --token=your-tokenStep 3: Run Tests
bash
yarn playwright testWhat Happens
- Global Setup validates binaries and cluster
- beforeAll creates namespace and deploys RHDH
- beforeEach navigates and logs in
- Tests run with assertions
- Cleanup deletes namespace (in CI)
Debugging
View in Browser
bash
yarn playwright test --headedDebug Mode
bash
yarn playwright test --debugView Report
bash
yarn playwright show-reportNext Steps
- Testing a Plugin - Complete workflow
- Keycloak OIDC Testing - Real auth