Skip to content

Examples

Copy-paste ready code examples for common scenarios.

Available Examples

ExampleDescription
Basic TestMinimal working test
Guest AuthenticationSimple guest login
Keycloak AuthenticationOIDC authentication
Catalog OperationsCatalog interactions
API OperationsGitHub/Backstage APIs
Custom DeploymentCustom configuration
Serial TestsShared browser session

Quick Reference

Minimal Test

typescript
import { test, expect } from "rhdh-e2e-test-utils/test";

test.beforeAll(async ({ rhdh }) => {
  await rhdh.deploy();
});

test("example", async ({ page }) => {
  await page.goto("/");
  await expect(page).toHaveTitle(/Developer Hub/);
});

With Login

typescript
import { test, expect } from "rhdh-e2e-test-utils/test";

test.beforeAll(async ({ rhdh }) => {
  await rhdh.configure({ auth: "keycloak" });
  await rhdh.deploy();
});

test.beforeEach(async ({ loginHelper }) => {
  await loginHelper.loginAsKeycloakUser();
});

test("logged in test", async ({ uiHelper }) => {
  await uiHelper.verifyHeading("Welcome");
});

With Page Object

typescript
import { test } from "rhdh-e2e-test-utils/test";
import { CatalogPage } from "rhdh-e2e-test-utils/pages";

test("catalog test", async ({ page, loginHelper }) => {
  await loginHelper.loginAsKeycloakUser();

  const catalogPage = new CatalogPage(page);
  await catalogPage.go();
  await catalogPage.search("my-component");
});

Released under the Apache-2.0 License.