### MockVaadin Setup Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Initializes the testing environment by fabricating VaadinSession, UI, and CurrentRequest. This setup is crucial before interacting with Vaadin APIs. ```kotlin MockVaadin.setup() ``` -------------------------------- ### Setup Simple UI with MockVaadin Source: https://github.com/mvysny/karibu-testing/blob/master/README.md Use this for simple apps with only the UI and no database. It instantiates your UI with the necessary Vaadin environment. ```java MockVaadin.setup { MyUI() } MockVaadin.tearDown() ``` -------------------------------- ### Setup App with ServletContextListeners and MockVaadin Source: https://github.com/mvysny/karibu-testing/blob/master/README.md For apps not using Vaadin-on-Kotlin but with database access, execute all ServletContextListeners before setting up the UI. ```java Bootstrap().contextInitialized(null) MockVaadin.setup { MyUI() } MockVaadin.tearDown() ``` -------------------------------- ### Discover and Setup Routes Source: https://github.com/mvysny/karibu-testing/blob/master/README.md Ensure your @Route-annotated view classes are discovered and registered. Use `new Routes().autoDiscoverViews("com.example.yourpackage")` and then call `MockVaadin.setup(routes)`. ```java new Routes().autoDiscoverViews("com.example.yourpackage") ``` ```java MockVaadin.setup(routes); ``` -------------------------------- ### Setup Vaadin-on-Kotlin App with MockVaadin Source: https://github.com/mvysny/karibu-testing/blob/master/README.md For Vaadin-on-Kotlin apps with database access, configure the data source and initialize Vaadin-on-Kotlin before setting up the UI. ```java VaadinOnKotlin.dataSourceConfig = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" VaadinOnKotlin.init() MockVaadin.setup { MyUI() } MockVaadin.tearDown() ``` -------------------------------- ### Setup MockVaadin Source: https://github.com/mvysny/karibu-testing/blob/master/README.md Call MockVaadin.setup() before your tests to avoid `UI.getCurrent() must not be null` errors. This is typically done in a @Before-annotated method. ```java MockVaadin.setup(); ``` -------------------------------- ### Setup Spring-based App with MockVaadin Source: https://github.com/mvysny/karibu-testing/blob/master/README.md For Spring-based apps, use Spring Test to bootstrap the app and then obtain the UI instance via the Spring injector. ```java MockVaadin.setup { beanFactory!!.getBean(MainUI::class.java) } MockVaadin.tearDown() ``` -------------------------------- ### Get Component Size Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Retrieves the size of a component. This is useful for layout assertions. ```kotlin _size() ``` -------------------------------- ### Build and Publish Library Source: https://github.com/mvysny/karibu-testing/blob/master/CONTRIBUTING.md Commands to clean, build, publish, and release the library to Maven Central. Ensure version is updated in build.gradle.kts before publishing. ```bash ./gradlew clean build publish closeAndReleaseStagingRepositories ``` -------------------------------- ### Build Project Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Perform a clean build of the project. The default task chain includes clean and build. ```gradle ./gradlew build ``` -------------------------------- ### Run All Tests Source: https://github.com/mvysny/karibu-testing/blob/master/CONTRIBUTING.md Execute all tests for all Vaadin versions using the Gradle wrapper. ```bash ./gradlew test ``` -------------------------------- ### Navigate UI Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Programmatically navigate the UI to a specified route. This is a server-side operation. ```kotlin UI.getCurrent().navigate("some-route") ``` -------------------------------- ### Prepare Next Snapshot Version Source: https://github.com/mvysny/karibu-testing/blob/master/CONTRIBUTING.md After release, update the version in build.gradle.kts to the next SNAPSHOT version. ```gradle version = "2.7.2-SNAPSHOT" ``` -------------------------------- ### Java API for Locators Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Provides Java-facing static helper classes for component location strategies. Use this when working with Karibu-Testing from Java. ```java LocatorJ ``` -------------------------------- ### Git Tagging and Pushing Source: https://github.com/mvysny/karibu-testing/blob/master/CONTRIBUTING.md Commands to commit, tag, and push changes and tags for a release. ```bash git tag the commit with the same tag name as the commit message above, e.g. `2.7.1` git push git push --tags ``` -------------------------------- ### Java API for Search Specifications Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Provides Java-facing static helper classes for defining search specifications. Use this when working with Karibu-Testing from Java. ```java SearchSpecJ ``` -------------------------------- ### Optimize View Auto-Discovery Source: https://github.com/mvysny/karibu-testing/blob/master/README.md For performance, discover routes once and reuse the `Routes` instance across tests. This avoids repeated slow auto-discovery. ```java new Routes().autoDiscoverViews("") ``` -------------------------------- ### Run Single Test Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Execute a single, specific test case. Useful for debugging. ```gradle ./gradlew :karibu-testing-v24:kt10-testrun-vaadin24:test --tests "AllTests.flow-build-info-json exists" ``` -------------------------------- ### Simulate Button Click Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Simulates a click event on a button component. This allows testing button actions directly. ```kotlin _click() ``` -------------------------------- ### Register Routes with Custom VaadinServlet Source: https://github.com/mvysny/karibu-testing/blob/master/README.md When using a custom VaadinServlet, ensure routes are registered by calling `routes.register(service.context as VaadinServletContext)` within the `createServletService()` method. ```java routes.register(service.context as VaadinServletContext) ``` -------------------------------- ### Run Specific Vaadin Variant Tests Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Execute tests for a specific Vaadin version. Replace the module name to target different variants. ```gradle ./gradlew :karibu-testing-v24:kt10-testrun-vaadin24:test ``` -------------------------------- ### Update Version for Release Source: https://github.com/mvysny/karibu-testing/blob/master/CONTRIBUTING.md Modify the version in build.gradle.kts to remove the SNAPSHOT suffix for a release. ```gradle version = "2.7.1" ``` -------------------------------- ### Set Component Value Source: https://github.com/mvysny/karibu-testing/blob/master/CLAUDE.md Sets the value of a component that implements the HasValue interface. This is useful for form input testing. ```kotlin _value= ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.