Quarkus Quinoa - Testing

By default, the Web UI is not build/served in @QuarkusTest. The goal is to be able to test your api without having to wait for the Web UI build.

Quinoa features a testing library to make it easier to test your Web UI (it also includes Quarkus Playwright) :


In order to enable the Web UI (build and serve) in a particular test, you can use the Enable test profile:

public class MyWebUITest {
    public void someTest() {
      // your test logic here

If you also want to run the tests included in your Web UI (i.e npm test) alongside this class, you can use the EnableAndRunTests test profile:

public class AllWebUITest {
    public void runTest() {
        // you don't need anything here, it will run your package.json "test"

The library also brings a very elegant way to do e2e testing using Quarkus Playwright:

import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Response;
import io.quarkiverse.playwright.WithPlaywright;
import io.quarkiverse.playwright.InjectPlaywright;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.net.URL;

public class MyWebUITest {
    BrowserContext context;

    URL url;

    void name() {
        final Page page = context.newPage();
        Response response = page.navigate(url.toString());
        Assertions.assertEquals("OK", response.statusText());


        String title = page.title();
        Assertions.assertEquals("My App", title);

        // Make sure the app content is ok
        String greeting = page.innerText(".quinoa");
        Assertions.assertEquals("Hello World", greeting);