Interface TestingLifecycleHook


public interface TestingLifecycleHook
If you need to hook into the testing lifecycle (e.g. you need to wait for any async operations to finish), provide your own custom implementation of this interface, then set it via TestingLifecycleHooks.setTestingLifecycleHook(TestingLifecycleHook).

Mocking server request end

Since Browserless Testing runs in the same JVM as the server and there is no browser, the boundaries between the client and the server become unclear. When looking into sources of any test method, it's really hard to tell where exactly the server request ends, and where another request starts.

You can establish an explicit client boundary in your test, by explicitly calling MockVaadin.clientRoundtrip(). However, since that would be both laborous and error-prone, the default operation is that Browserless Testing pretends as if there was a client-server roundtrip before every component lookup via the _get/_find/_expectNone/ _expectOne call. Therefore, MockVaadin.clientRoundtrip() is called from awaitBeforeLookup() by default.

For internal use only. May be renamed or removed in a future release.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A hook that does nothing beyond the default implementations below.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Invoked after every component lookup.
    default void
    Invoked before every component lookup.
    default List<com.vaadin.flow.component.Component>
    getAllChildren(com.vaadin.flow.component.Component component)
    Provides all children of given component.
  • Field Details

    • DEFAULT

      static final TestingLifecycleHook DEFAULT
      A hook that does nothing beyond the default implementations below.
  • Method Details

    • awaitBeforeLookup

      default void awaitBeforeLookup()
      Invoked before every component lookup. You can e.g. wait for any async operations to finish and for the server to settle down.

      The default implementation calls the MockVaadin.clientRoundtrip() method. When implementing this method, you should also call MockVaadin.clientRoundtrip() (or simply call super).

    • awaitAfterLookup

      default void awaitAfterLookup()
      Invoked after every component lookup. You can e.g. wait for any async operations to finish and for the server to settle down. Invoked even if the _get()/_find()/_expectNone() function fails.
    • getAllChildren

      default List<com.vaadin.flow.component.Component> getAllChildren(com.vaadin.flow.component.Component component)
      Provides all children of given component. The default implementation returns the children provided by the first registered ComponentSupport that knows the component (for example the header, footer and editor components of a Grid, or the items of a sub-menu). Otherwise it returns the component's own children together with its element-tree children, including virtual ones; for templates and Composite only the component's own children are returned.
      Parameters:
      component - the component whose children to return.
      Returns:
      the children of the component.