Skip to main content

Overview

Drama Finder integrates seamlessly with Spring Boot to provide robust end-to-end testing for Vaadin applications. This guide walks you through setting up your test infrastructure using the AbstractBasePlaywrightIT base class.

Project Setup

1

Add Drama Finder dependency

Add the Drama Finder library as a test dependency in your pom.xml:
2

Configure Maven Failsafe Plugin

Integration tests in Drama Finder use the maven-failsafe-plugin and follow the *IT.java naming convention:
Unit tests (using *Test.java) run with Surefire, while integration tests (using *IT.java) run with Failsafe during the verify phase.
3

Create base test class

Create a Spring-specific base class that extends AbstractBasePlaywrightIT:
This class automatically injects the random port that Spring Boot assigns to your test server.
4

Create your first test

Create a test class that extends your Spring base class:

Understanding AbstractBasePlaywrightIT

The AbstractBasePlaywrightIT class provides essential infrastructure for your tests:

Lifecycle Management

Vaadin Flow Readiness Check

The base class includes a WAIT_FOR_VAADIN_SCRIPT that ensures Vaadin Flow is fully loaded before tests run:
This prevents flaky tests by ensuring all Vaadin clients are inactive before proceeding.

Default Timeouts

Adjust these timeouts in your base class if your application needs more time to load or respond.

Accessing Playwright Objects

The base class provides protected accessors:

Running Tests

Run all integration tests

Or with the integration test profile:

Run a single test class

Run a specific test method

Debug with visible browser

By default, tests run in headless mode. To see the browser:
Or create a debug profile in your pom.xml:
Then run:

Headless Mode Configuration

The AbstractBasePlaywrightIT class checks for headless mode in this order:
  1. System property: -Dheadless=false
  2. Environment variable: HEADLESS=false
  3. Default: true (headless)

HasTestView Interface

Implement the HasTestView interface to specify the view path for your test:

Example

If you don’t override getView(), tests will navigate to the root path (/).

Thread Safety and Parallel Execution

The base class uses ThreadLocal storage for Playwright, Browser, and Page instances, making it safe for parallel test execution:
To enable parallel execution in Maven:

CI/CD Integration

GitHub Actions

GitLab CI

Playwright browsers are downloaded automatically on first run, but explicitly installing them in CI ensures consistent behavior.

Troubleshooting Setup Issues

Browser not found

If you see “Executable doesn’t exist” errors, install Playwright browsers:

Tests timing out

Increase timeouts in your base class:

Port conflicts

Spring Boot automatically assigns a random port with WebEnvironment.RANDOM_PORT. If you need a specific port:

Vaadin not loading

If the WAIT_FOR_VAADIN_SCRIPT times out, check:
  • Dev mode bundle is built (mvn vaadin:build-frontend)
  • No JavaScript errors in console (enable debug mode to see)
  • Network requests are completing successfully

Next Steps

Best Practices

Learn best practices for maintainable tests

Common Patterns

Explore real-world testing scenarios

Troubleshooting

Solutions to common testing issues

Element Reference

Browse all available element wrappers