This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the Vaadin Flow Components repository containing Vaadin Flow wrappers for Vaadin web components. It's a multi-module Maven project with individual component modules following a consistent structure.
- Java 21+
- Maven
- Vaadin Flow 25+
- JUnit for unit testing
- Mockito for mocking in unit tests
- Vaadin TestBench for integration tests
- Jetty for running integration test servers
Each component module follows a consistent parent-child structure:
vaadin-{component}-flow-parent/ # Parent module for a component
├── vaadin-{component}-flow/ # Main component implementation
├── vaadin-{component}-flow-integration-tests/ # Integration tests
└── vaadin-{component}-testbench/ # TestBench elements
Shared modules used across components:
vaadin-flow-components-shared-parent/vaadin-flow-components-base: Common utilities, mixins, and base classesvaadin-flow-components-shared-parent/vaadin-flow-components-test-util: Testing utilities
- Component classes are located in
src/main/java/com/vaadin/flow/component/{component}/* - Extend Flow
Componentand implement mixin interfaces likeHasText,HasEnabled,ClickNotifier - Use
@Tagand@JsModuleannotations to link to the corresponding Vaadin web component - Can have theme variants by implementing the
HasThemeVariantinterface and defining an enum for variants extending fromThemeVariant - Some components use additional client-side JavaScript for integrating with the web component or to add extra functionality. These so-called "connectors" are located in
src/main/resources/META-INF/resources/frontend - Connector initialization, as well as any inline JavaScript run with
Element.executeJs(), are run in the component's attach handler to ensure they are always run again when Flow creates a new element for the same component instance on the client side
- Unit tests:
- Using JUnit 6
- Located in component modules
- Integration tests:
- Using JUnit 4
- TestBench-based browser tests, located in separate IT modules
- Each test consists of a test setup in form of a Vaadin Flow view and a JUnit test class
- Both are linked using
@Routeand@TestPathannotations - New integration tests should extend from
com.vaadin.tests.AbstractComponentIT
# Build entire project
mvn clean install -DskipTests
# Build a component module
mvn clean install -pl vaadin-{component}-flow-parent -DskipTests
# Run all unit tests for a component
mvn test -pl vaadin-{component}-flow-parent/vaadin-{component}-flow
# Run specific unit tests for a component
mvn test -pl vaadin-{component}-flow-parent/vaadin-{component}-flow -Dtest='{file-pattern}'
# Run all integration tests for a component
mvn verify -am -pl vaadin-{component}-flow-parent/vaadin-{component}-flow-integration-tests -DskipUnitTests
# Run specific integration tests for a component
mvn verify -am -pl vaadin-{component}-flow-parent/vaadin-{component}-flow-integration-tests -Dit.test='{file-pattern}' -DskipUnitTests
# Start integration test server for a component
mvn package jetty:run -Dvaadin.pnpm.enable -Dvaadin.frontend.hotdeploy=true -am -B -q -DskipTests -pl vaadin-{component}-flow-parent/vaadin-{component}-flow-integration-testsNotes on test commands:
- Running a single integration test method requires adding a "*" wildcard after the method name (e.g.
-Dit.test='ButtonIT#textMatches*'). This is because the TestBench test runner modifies the method names to include browser information (e.g.textMatches[any_Chrome_]). - Integration test server can be used for testing pages manually using Playwright MCP, if installed
- Server needs to be restarted after code changes
- Integration tests can fail if the 8080 port is already in use. At that point stop and ask the user whether to kill the process using that port. If you started the server yourself and want to run tests against it, add
-DskipJettyto the integration test command. - When waiting for the server to start, use
TaskOutputwithblock=falseto poll the background task output for the message "Frontend compiled successfully" rather than using arbitrary sleep commands. - To stop a running Jetty server, run
mvn jetty:stop -pl vaadin-{component}-flow-parent/vaadin-{component}-flow-integration-tests. Do not useTaskStopon the backgroundjetty:runtask — that terminates the Maven wrapper but leaves the forked Jetty JVM running and holding port 8080.
# Format code
mvn spotless:apply
# Run checkstyle validation
mvn checkstyle:check