Running Browser Tests
Start your web server for the run, rerun only what failed, and run browser tests in CI.
Browser specs are regular TestBox bundles, so every runner can run them. The BoxLang CLI runner adds options that make browser test runs smooth: it can start your application before the tests and stop it afterwards, rerun only what failed last time, and retry flaky specs.
./testbox/run --directory=tests.browser \
--web-server="boxlang-miniserver --port 8080" \
--retries=1BoxLang Runner Options
--web-server
A shell command that starts a web server before the tests run.
--web-server-url
http://localhost:8080
The URL polled until the server answers. Also the default baseURL of browser bundles.
--web-server-timeout
60
How long to wait for the server to answer, in seconds.
--failed
false
Run only the bundles and specs that failed or errored in the last run.
--retries and --failed work for any bundle, .bx or .cfc, browser test or not.
Start a Web Server for the Run

Browser tests need your application running. With --web-server, the runner starts it for you:
It runs the command with
sh -c(cmd /con Windows) from the directory you run the tests from.It polls
--web-server-urluntil the server answers with an HTTP status below 500.It stores the URL in
server.testbox.webServerURL, which every browser bundle without abaseURLannotation uses as its base URL, sopage.visit( "/login" )just works.It runs the tests.
It stops the server and its child processes after the tests, whether they passed, failed or threw.
If the server does not answer within --web-server-timeout seconds, or its command exits first, the runner stops it, prints the reason with the command and the last lines it printed, and exits with code 1 without running the tests.
Prefer to start the server yourself? Skip --web-server and set the baseURL annotation on your bundles, or the BX_PLAYWRIGHT_BASEURL environment variable.
Rerun What Failed: --failed

Every run of the BoxLang runner writes a .testbox-failed.json file to the report path (--reportpath, tests/results by default) with the bundles and spec ids that failed or errored:
--failed reads that file and runs only those bundles and specs:
A bundle that failed outside of a spec, for example in
beforeAll()orafterAll(), is broken, not flaky: it goes tobundleErrorsand is not rerun.--failedlists those bundles so you can fix them and run them directly. The other failed bundles still rerun only their failed specs.When everything passed, every array is empty.
--failedthen printsNo failed tests recorded in [...], nothing to run.and runs nothing. The same happens when the file is missing.The rerun writes the file again, so repeat
--faileduntil it has nothing left to run.Use the same
--reportpathfor the full run and the rerun.
Combine it with retries for a forgiving rerun: ./testbox/run --failed --retries=1.
Run Failed in the HTML reports
The web runners keep no state, so they need no file. When something failed, the Simple, Min, Dot and Doc reports show a Run Failed (N) button next to Run All. Its link is built from the report on screen: ?testBundles=...&testSpecs=... with the failed bundles and spec ids. Click it, fix, click it again. When the spec ids would make the link too long, it reruns the failed bundles whole. Bundles that failed outside of a spec are left out, like with --failed.
From code
Both use TestResult.getFailedTargets(), available on every engine:
Debugging a Failing Browser Spec
Run the bundle with a visible browser: annotate the bundle with
@browserProfile( "debug" ), or run withBX_PLAYWRIGHT_PROFILE=debugwhen the bundle has nobrowserProfile. Thedebugprofile is headed, slowed down and records every artifact.Open the trace a failure attached with
bxplaywright show-trace path/to/trace.zip. It shows every action, the page before and after it, the console and the network.Record the steps of a new spec as BoxLang code with
bxplaywright codegen http://localhost:8080.

More in the bx-playwright testing guide.
Continuous Integration
A CI run needs the bx-playwright module, a browser and its system libraries, your application running, and somewhere to keep the screenshots and traces of failed specs:
Install the browser with
bxplaywright install chromium --with-deps(the--with-depsflag installs the system libraries on Linux).Use the
ciprofile, throughBX_PLAYWRIGHT_PROFILE=cior a@browserProfile( "ci" )annotation: headless, with a screenshot, trace and videos kept for every failed context.Cache
~/.boxlang/playwright(driver, Node.js and browsers) between runs.Start the application with
--web-server.Upload
tests/resultsand the artifacts when the job fails.
GitHub Actions
A complete workflow: it installs BoxLang with bx-playwright, installs TestBox with CommandBox, caches the browsers, runs the tests against the BoxLang MiniServer with one retry, and uploads the reports, screenshots, traces and videos of failed tests.
Adapt the run step to your project: point --directory at your specs, and replace the MiniServer command with whatever starts your application. Artifacts go to ~/.boxlang/playwright/artifacts unless you set the bx-playwright artifacts.directory setting. Download the browser-test-results artifact from the failed run and open a trace with bxplaywright show-trace trace.zip.
Jenkins and GitLab
Run with --reporter=junit and publish tests/results as a JUnit report. Each test case lists its attachments in <system-out> as [[ATTACHMENT|path]] lines, which the Jenkins JUnit Attachments plugin and GitLab test reports pick up. See Attachments in Reports.
See Continuous Integration for more CI setups.
Last updated
Was this helpful?