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 theAbstractBasePlaywrightIT 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 This class automatically injects the random port that Spring Boot assigns to your test server.
AbstractBasePlaywrightIT:4
Create your first test
Create a test class that extends your Spring base class:
Understanding AbstractBasePlaywrightIT
TheAbstractBasePlaywrightIT class provides essential infrastructure for your tests:
Lifecycle Management
Vaadin Flow Readiness Check
The base class includes aWAIT_FOR_VAADIN_SCRIPT that ensures Vaadin Flow is fully loaded before tests run:
Default Timeouts
Accessing Playwright Objects
The base class provides protected accessors:Running Tests
Run all integration tests
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:pom.xml:
Headless Mode Configuration
TheAbstractBasePlaywrightIT class checks for headless mode in this order:
- System property:
-Dheadless=false - Environment variable:
HEADLESS=false - Default:
true(headless)
HasTestView Interface
Implement theHasTestView interface to specify the view path for your test:
Example
Thread Safety and Parallel Execution
The base class usesThreadLocal storage for Playwright, Browser, and Page instances, making it safe for parallel test execution:
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 withWebEnvironment.RANDOM_PORT. If you need a specific port:
Vaadin not loading
If theWAIT_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