Playwright

UmbNav uses Playwright for end-to-end testing of the backoffice user interface. These tests verify that editors can create, modify, and manage navigation items.

Setup

Prerequisites

  • Node.js 18 or higher

  • A running Umbraco instance with test content

  • Test user credentials

Installation

cd Umbraco.Community.UmbNav

# Install dependencies
npm install

# Install Playwright browsers
npx playwright install

Environment Configuration

Create a .env file in the Umbraco.Community.UmbNav directory:

UMBRACO_URL=https://localhost:44302
[email protected]
UMBRACO_PASSWORD=your-password

Running Tests

All Tests

Specific Test File

Headed Mode (See Browser)

Debug Mode

Specific Browser

Generate Report

Test Structure

Test Examples

Adding a Content Item

Validation Test

Configuration-Based Test

Configuration

playwright.config.ts

Using Umbraco Test Helpers

UmbNav tests use @umbraco/playwright-testhelpers for common operations:

Selectors for UmbNav Components

Main Property Editor

Add Buttons

Modals

Writing New Tests

Test Template

Best Practices

  1. Use descriptive test names - Kebab-case for files, descriptive for tests

  2. Wait for elements - Use waitFor() before interactions

  3. Use exact matches - { name: 'Add', exact: true } avoids ambiguity

  4. Test one thing - Each test should verify one behavior

  5. Clean up - Tests shouldn't leave side effects

  6. Use page object pattern - Extract common selectors

Debugging

Debug Mode

Trace Viewer

Screenshots

Videos

In playwright.config.ts:

CI Integration

Tests are designed to run in CI environments:

In CI mode:

  • forbidOnly: true - Fails if test.only is present

  • retries: 2 - Retries flaky tests

  • workers: 1 - Runs sequentially to avoid conflicts

Last updated

Was this helpful?