Getting started with Playwright

Installation

To begin E2E testing with Playwright in an Aurelia 1 project, you'll need to install the necessary dependencies:

# Install Playwright
npm install --save-dev @playwright/test

# Install browser drivers
npx playwright install

Project Setup

1. Configuration File

Create a playwright.config.js in your project root:

const { defineConfig } = require('@playwright/test');

module.exports = defineConfig({
  // Test directory
  testDir: './tests/e2e',
  
  // Browser configurations
  use: {
    baseURL: 'http://localhost:9000', // Typical Aurelia dev server
    trace: 'on-first-retry',
    screenshot: 'only-on-failure'
  },
  
  // Optional: Run in headless or headed mode
  headless: true,
  
  // Reporters
  reporter: [
    ['html', { open: 'never' }],
    ['line']
  ],
  
  // Timeout settings
  timeout: 30000,
  expect: {
    timeout: 5000
  }
});

2. Project Structure

Recommended E2E test structure:

Basic Concepts

Writing Your First Test

Running Tests

Add scripts to your package.json:

Aurelia-Specific Considerations

Browser Support

Playwright supports multiple browsers out of the box:

  • Chromium

  • Firefox

  • WebKit

Configure in playwright.config.js:

Best Practice: Start with Chromium for development, then expand to other browsers for comprehensive testing.

  1. Set up your initial configuration

  2. Create page object classes

  3. Write your first test scenarios

  4. Integrate with your CI/CD pipeline

Last updated

Was this helpful?