developers

No menu items for this category
OpenMetadata Documentation

Playwright Integration Tests

Before proceeding, ensure that you have:

  1. Completed the OpenMetadata UI setup - Follow all pre-requisites in the OpenMetadata UI section, which covers Node.js, Yarn, and other dependencies.

  2. Services running - Playwright tests require all OpenMetadata services to be running in a clean state, including Elastic Search, Airflow, and MySQL database.

The quickest way to bring all services up and running locally is to use the Docker script:

After completing the UI setup, install Playwright and its browsers:

Note: The Playwright browser installation is only needed once per machine. These browsers are used to run tests in different browser environments (Chromium, Firefox, WebKit).

To run all tests in headless mode (without browser UI):

For interactive debugging and test development, use the Playwright UI mode:

This will open the Playwright Test Runner UI where you can:

  • View all available tests
  • Run individual tests or test suites
  • Debug tests with breakpoints
  • View test traces and screenshots
  • Inspect the DOM during test execution

To run a specific test file:

To run tests matching a specific pattern:

Playwright supports testing on multiple browsers:

Run tests from specific directories:

The configuration excludes certain tests by default:

  • Nightly tests are excluded from regular test runs (testIgnore: ['**/nightly/**'])
  • Data Insight tests run in a separate project with dependencies

Tests are organized into logical categories:

  • Features: Tests for specific features (e.g., ActivityFeed, BulkImport, Permissions)
  • Flow: End-to-end user workflows (e.g., AddRoleAndAssignToUser, GlobalSearch)
  • Pages: Tests for individual pages (e.g., Login, Teams, DataInsight)
  • VersionPages: Tests for entity version management
  • Nightly: Long-running tests executed in nightly builds

Create a new test file in the playwright/e2e directory:

Playwright provides a code generator to help create tests:

This will open a browser where you can interact with your application, and Playwright will generate the corresponding test code.

After running tests, view the detailed HTML report:

Playwright automatically captures:

  • Screenshots on failure
  • Test traces for debugging
  • Videos of test execution (configurable)

Artifacts are stored in playwright/output/test-results/

The Playwright configuration is defined in playwright.config.ts. Key configuration options include:

  • Test directory: ./playwright/e2e
  • Base URL: Default http://localhost:8585 (configurable via PLAYWRIGHT_TEST_BASE_URL)
  • Parallel execution: Tests run in parallel by default
  • Retries: Configured for CI environments (1 retry on CI, 0 locally)
  • Workers: 4 workers on CI, system default locally
  • Reporters: List, HTML, GitHub Actions, and Blob reporters
  • Timeout: 60 seconds per test (configurable)
  • Traces: Captured on first retry
  • Screenshots: Captured on failure only

You can configure test behavior using environment variables:

The configuration includes several test projects:

  • setup: Authentication setup that runs before tests
  • restore-policies: Cleanup that runs after tests
  • chromium: Main test suite on Chrome
  • data-insight-application: Data Insight app setup
  • Data Insight: Tests specific to Data Insight features

For CI environments, tests are configured to:

  • Run with retries on failure
  • Use optimized parallel execution
  • Generate GitHub Actions compatible reports
  • Fail fast on test.only() in source code
  1. Tests failing due to stale data

    • Reset the database to a clean state
    • Restart the OpenMetadata server
  2. Browser installation issues

  3. Authentication failures

    • Clear the auth storage state
  4. Timeout issues

    • Increase timeout in playwright.config.ts
    • Check if services are fully started before running tests
  5. Flaky tests

    • Use Playwright's built-in retry mechanism
    • Ensure proper wait conditions in tests
    • Use data-testid attributes for reliable element selection
  1. Use Page Object Model: Organize page interactions in separate classes
  2. Data-testid attributes: Use consistent test IDs for element selection
  3. Avoid hard-coded waits: Use Playwright's built-in wait conditions
  4. Clean test data: Ensure tests clean up after themselves
  5. Parallel execution: Write tests to be independent and parallelizable
  6. Meaningful assertions: Use descriptive assertion messages
  7. Reusable utilities: Create utility functions for common operations