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
Step 1: Create Project
bash
mkdir my-plugin-e2e
cd my-plugin-e2e
yarn init -yStep 2: Install Dependencies
bash
yarn add @playwright/test rhdh-e2e-test-utils typescript dotenvStep 3: Create Configuration Files
playwright.config.ts:
typescript
import { defineConfig } from "rhdh-e2e-test-utils/playwright-config";
import dotenv from "dotenv";
dotenv.config({ path: `${import.meta.dirname}/.env` });
export default defineConfig({
projects: [
{
name: "my-plugin",
},
],
});tsconfig.json:
json
{
"extends": "rhdh-e2e-test-utils/tsconfig",
"include": ["tests/**/*.ts", "playwright.config.ts"]
}.env:
bash
RHDH_VERSION="1.5"
INSTALLATION_METHOD="helm"
SKIP_KEYCLOAK_DEPLOYMENT=trueStep 4: Create Test Directory
bash
mkdir -p tests/config tests/specsStep 5: Create Config Files
tests/config/app-config-rhdh.yaml:
yaml
app:
title: My First Test Instancetests/config/dynamic-plugins.yaml:
yaml
includes:
- dynamic-plugins.default.yamltests/config/rhdh-secrets.yaml:
yaml
apiVersion: v1
kind: Secret
metadata:
name: rhdh-secrets
type: Opaque
stringData: {}Step 6: 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 7: Login to OpenShift
bash
oc login --server=https://api.your-cluster.com:6443 --token=your-tokenStep 8: 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