> Markdown version of [Testing](https://vaadin.com/docs/next/building-apps/testing). Section index: [llms.txt](https://vaadin.com/docs/next/building-apps/llms.txt)

# Testing

These guides show you how to test the server-side behavior of Flow views using browserless tests. Start by [choosing the setup for your application framework](https://vaadin.com/docs/next/building-apps/testing/browserless.md#choose-your-framework), then choose a guide for the behavior you need to verify.

Browserless tests run against Java components without a browser. Use end-to-end (E2E) tests, which run in a real browser, when you need to verify rendering, client-side behavior, or real browser interactions. See [the testing reference](https://vaadin.com/docs/next/flow/testing.md#comparison) for a comparison of the approaches.

## <a id="choosing-what-to-test"></a>Choosing What to Test

Each layer of your application is tested in its own way. The following table shows where to find guidance for each:

| What you test                                                           | Kind of test                                                 | Guidance                                                                                                                                                                                                                                                                                                                                                                      |
| ----------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Application services and their rules, including access control          | Spring integration tests that call the service               | [Test the Service](https://vaadin.com/docs/next/getting-started/tutorial/add-tests.md#test-the-service) in the tutorial, [Testing Method Security](https://vaadin.com/docs/next/building-apps/security/protect-services.md#testing-method-security), and [Testing Record Rules](https://vaadin.com/docs/next/building-apps/security/protect-services.md#testing-record-rules) |
| Queries, migrations, and the database schema                            | Integration tests against the same database as in production | [Add Testcontainers](https://vaadin.com/docs/next/building-apps/forms-data/persistence/replace-h2.md#add-testcontainers), and [Testcontainers](https://docs.spring.io/spring-boot/reference/testing/testcontainers.html) in the Spring Boot documentation                                                                                                                     |
| Flow views                                                              | Browserless tests                                            | The guides listed below                                                                                                                                                                                                                                                                                                                                                       |
| Rendering, client-side behavior, and the whole application in a browser | End-to-end tests                                             | [Choosing an End-to-End Testing Tool](https://vaadin.com/docs/next/flow/testing.md#e2e-tools)                                                                                                                                                                                                                                                                                 |

Service and browserless tests are fast and don’t need a browser, so they can cover most of your application, including its use cases from start to finish. Keep end-to-end tests for what only a browser can show, as described in [Keep a Thin Layer of End-to-End Tests](#e2e-tests).

Browserless tests can’t test [React views](https://vaadin.com/docs/next/building-apps/react.md), because React views run in the browser. Test the browser-callable services of a React view like any other application service. Test the view itself with end-to-end tests, or with the JavaScript tools described in [Test React Views](https://vaadin.com/docs/next/building-apps/react/test-views.md).

To run the tests on every change, see [Build on CI](https://vaadin.com/docs/next/building-apps/production/ci.md).

### <a id="features"></a>Choosing a Test for a Feature

Browserless tests cover most features of Flow views. Some features need a simulator or a test double in place of the browser or an external service, and others need a real browser. The following table shows the kind of test for features where the choice isn’t obvious:

| Feature                                                       | Kind of test                                                                                                                                                                              | Guidance                                                                                                                     |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Signals and component bindings                                | Browserless tests                                                                                                                                                                         | [Test Signal-Based Views](https://vaadin.com/docs/next/building-apps/testing/browserless/test-signals.md)                    |
| Shared signals between users                                  | Browserless tests, with a window for each user                                                                                                                                            | [Share Signals between Users](https://vaadin.com/docs/next/building-apps/testing/browserless/test-multiple-users.md#signals) |
| Geolocation                                                   | Browserless tests, with the geolocation simulator in place of the browser                                                                                                                 | [Testing](https://vaadin.com/docs/next/flow/browser-apis/geolocation-api.md#testing) on the Geolocation page                 |
| Master-Detail Layout                                          | Browserless tests for the content of the master and detail areas. End-to-end tests for whether the layout shows the detail area as an overlay, which depends on the space in the browser. | [Component Testers](https://vaadin.com/docs/next/flow/testing/browserless/component-testers.md#common-testers)               |
| Slider                                                        | Browserless tests                                                                                                                                                                         | [Component Testers](https://vaadin.com/docs/next/flow/testing/browserless/component-testers.md#common-testers)               |
| Message List attachments                                      | Browserless tests                                                                                                                                                                         | [Component Testers](https://vaadin.com/docs/next/flow/testing/browserless/component-testers.md#common-testers)               |
| AI integration, such as a chat built with the AI Orchestrator | Browserless tests, with a scripted LLM provider in place of the model                                                                                                                     | [Test AI-Powered Views](https://vaadin.com/docs/next/building-apps/testing/browserless/test-ai-views.md)                     |
| Clipboard                                                     | End-to-end tests. The browser copies, reads, and pastes, and browserless tests have no clipboard simulator.                                                                               | [Choosing an End-to-End Testing Tool](https://vaadin.com/docs/next/flow/testing.md#e2e-tools)                                |

## <a id="e2e-tests"></a>Keep a Thin Layer of End-to-End Tests

Browserless tests prove behavior, not rendering. They can’t show that:

- the theme and the CSS look right,

- the client-side JavaScript of a component works,

- the layout works in real browsers and at different screen sizes, or

- add-ons and custom components render.

Keep a few end-to-end tests in a real browser for these, also as a safety net when you upgrade Vaadin or an add-on. Typical smoke tests check that:

- the most important views open,

- custom components and add-ons render,

- the browser console shows no JavaScript errors,

- the login flow works, and

- each kind of gesture, such as drag and drop, reaches the server-side code that handles it; see [Design Gestures for Testing](https://vaadin.com/docs/next/building-apps/testing/browserless/test-custom-components.md#gestures).

Don’t repeat the use cases in the end-to-end tests: the rules behind them belong in the faster browserless tests. A component with client-side code of its own also needs end-to-end tests for that code, in the component’s own module.

## <a id="guides"></a>Guides

- [Browserless Testing](https://vaadin.com/docs/next/building-apps/testing/browserless.md): Choose the browserless test setup for Spring Boot, Java EE/CDI, Quarkus, or plain Java, then test your Flow views.

`3E1E2938-89FF-4EFD-9EE2-658369A06F3A`
