Playwright Integration Tests
Pre-requisites
Before proceeding, ensure that you have:
Completed the OpenMetadata UI setup - Follow all pre-requisites in the OpenMetadata UI section, which covers Node.js, Yarn, and other dependencies.
Services running - Playwright tests require all OpenMetadata services to be running in a clean state, including Elastic Search, Airflow, and MySQL database.
Starting Required Services
The quickest way to bring all services up and running locally is to use the Docker script:
Installing Playwright
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).
Running Playwright Tests
Running Tests in Headless Mode
To run all tests in headless mode (without browser UI):
Running Tests with UI Mode
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
Running Specific Tests
To run a specific test file:
To run tests matching a specific pattern:
Running Tests on Different Browsers
Playwright supports testing on multiple browsers:
Running Tests by Category
Run tests from specific directories:
Excluding Tests
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
Test Structure and Organization
Test Directory Structure
Test Categories
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
Writing New Tests
Create a new test file in the playwright/e2e
directory:
Debugging Tests
Using Debug Mode
Using Playwright Inspector
Generating Test Code
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.
Test Reports and Artifacts
Viewing HTML Reports
After running tests, view the detailed HTML report:
Test Artifacts
Playwright automatically captures:
- Screenshots on failure
- Test traces for debugging
- Videos of test execution (configurable)
Artifacts are stored in playwright/output/test-results/
Configuration
The Playwright configuration is defined in playwright.config.ts
. Key configuration options include:
- Test directory:
./playwright/e2e
- Base URL: Default
http://localhost:8585
(configurable viaPLAYWRIGHT_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
Environment Variables
You can configure test behavior using environment variables:
Test Projects
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
CI/CD Integration
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
Troubleshooting
Common Issues and Solutions
Tests failing due to stale data
- Reset the database to a clean state
- Restart the OpenMetadata server
Browser installation issues
Authentication failures
- Clear the auth storage state
Timeout issues
- Increase timeout in playwright.config.ts
- Check if services are fully started before running tests
Flaky tests
- Use Playwright's built-in retry mechanism
- Ensure proper wait conditions in tests
- Use data-testid attributes for reliable element selection
Best Practices
- Use Page Object Model: Organize page interactions in separate classes
- Data-testid attributes: Use consistent test IDs for element selection
- Avoid hard-coded waits: Use Playwright's built-in wait conditions
- Clean test data: Ensure tests clean up after themselves
- Parallel execution: Write tests to be independent and parallelizable
- Meaningful assertions: Use descriptive assertion messages
- Reusable utilities: Create utility functions for common operations