Shared Playwright test fixtures using Lazytest around hooks.
Provides dynamic vars for Playwright instance, browser, and page, along with around hooks that can be used with Lazytest's :context metadata.
Usage: (ns my-test (:require [com.blockether.spel.allure :refer [defdescribe describe it expect]] [com.blockether.spel.test-fixtures :refer [page with-playwright with-browser with-page]]))
(defdescribe my-test (describe "with full setup" {:context [with-playwright with-browser with-page]} (it "can access page" (expect (some? page)))))
Import defdescribe, describe, it, and expect from
com.blockether.spel.allure instead of lazytest.core for a single
require. expect auto-creates an Allure step per expectation with
its own pass/fail status. The other three delegate to lazytest.core
unchanged. All are zero-overhead when not running under the Allure
reporter.
Shared Playwright test fixtures using Lazytest around hooks.
Provides dynamic vars for Playwright instance, browser, and page,
along with around hooks that can be used with Lazytest's :context metadata.
Usage:
(ns my-test
(:require
[com.blockether.spel.allure :refer [defdescribe describe it expect]]
[com.blockether.spel.test-fixtures :refer [*page* with-playwright with-browser with-page]]))
(defdescribe my-test
(describe "with full setup" {:context [with-playwright with-browser with-page]}
(it "can access page"
(expect (some? *page*)))))
Import `defdescribe`, `describe`, `it`, and `expect` from
`com.blockether.spel.allure` instead of `lazytest.core` for a single
require. `expect` auto-creates an Allure step per expectation with
its own pass/fail status. The other three delegate to `lazytest.core`
unchanged. All are zero-overhead when not running under the Allure
reporter.Dynamic var holding the current Browser instance.
Dynamic var holding the current Browser instance.
Dynamic var holding an APIRequestContext bound to the current BrowserContext. API calls through this context automatically appear in Playwright traces (unlike standalone APIRequestContexts). Bound by with-page (auto-tracing) and with-traced-page. nil otherwise.
Dynamic var holding an APIRequestContext bound to the current BrowserContext. API calls through this context automatically appear in Playwright traces (unlike standalone APIRequestContexts). Bound by with-page (auto-tracing) and with-traced-page. nil otherwise.
Dynamic var holding the current BrowserContext. Bound by with-page (auto-tracing) and with-traced-page. nil otherwise. Useful for accessing context-level APIs like (.request ctx) for traced API calls, cookies, routes, etc.
Dynamic var holding the current BrowserContext. Bound by with-page (auto-tracing) and with-traced-page. nil otherwise. Useful for accessing context-level APIs like (.request ctx) for traced API calls, cookies, routes, etc.
Dynamic var holding the current Page instance.
Dynamic var holding the current Page instance.
Dynamic var holding the current Playwright instance.
Dynamic var holding the current Playwright instance.
(interactive?)Returns true when tests should run in interactive (headed) mode.
Checks system property spel.interactive first, then env var SPEL_INTERACTIVE.
Any truthy string value (e.g. "true", "1", "yes") enables interactive mode.
Usage: clojure -J-Dspel.interactive=true -M:test SPEL_INTERACTIVE=true clojure -M:test
Returns true when tests should run in interactive (headed) mode. Checks system property `spel.interactive` first, then env var `SPEL_INTERACTIVE`. Any truthy string value (e.g. "true", "1", "yes") enables interactive mode. Usage: clojure -J-Dspel.interactive=true -M:test SPEL_INTERACTIVE=true clojure -M:test
Around hook: creates a BrowserContext with Playwright tracing for API-only tests (no page needed).
Headless by default. Set SPEL_INTERACTIVE=true env var or
-Dspel.interactive=true system property to run headed (interactive).
Requires pw to be bound (use with with-playwright). Binds: browser-context — the BrowserContext (for advanced use) browser-api — APIRequestContext from the context; all HTTP calls through this appear in the Playwright trace
When the Allure reporter is active, also enables tracing and HAR recording: allure/trace-path — where the trace zip will be written allure/har-path — where the HAR file will be written
When the Allure reporter is NOT active, browser-api is still bound (backed by a real BrowserContext) so tests work consistently — just without trace overhead.
Usage: {:context [with-playwright with-test-server with-api-tracing]}
(it "calls API with tracing" (let [resp (api/api-get browser-api (str test-server-url "/health"))] (expect (= 200 (api/api-response-status resp)))))
Around hook: creates a BrowserContext with Playwright tracing
for API-only tests (no page needed).
Headless by default. Set `SPEL_INTERACTIVE=true` env var or
`-Dspel.interactive=true` system property to run headed (interactive).
Requires *pw* to be bound (use with with-playwright).
Binds:
*browser-context* — the BrowserContext (for advanced use)
*browser-api* — APIRequestContext from the context; all HTTP calls
through this appear in the Playwright trace
When the Allure reporter is active, also enables tracing and HAR recording:
allure/*trace-path* — where the trace zip will be written
allure/*har-path* — where the HAR file will be written
When the Allure reporter is NOT active, *browser-api* is still bound
(backed by a real BrowserContext) so tests work consistently — just
without trace overhead.
Usage:
{:context [with-playwright with-test-server with-api-tracing]}
(it "calls API with tracing"
(let [resp (api/api-get *browser-api*
(str *test-server-url* "/health"))]
(expect (= 200 (api/api-response-status resp)))))Around hook: launches and closes a Chromium browser.
Headless by default. Set SPEL_INTERACTIVE=true env var or
-Dspel.interactive=true system property to run headed (interactive).
Requires pw to be bound (use with with-playwright). Binds the Browser instance to browser.
Around hook: launches and closes a Chromium browser. Headless by default. Set `SPEL_INTERACTIVE=true` env var or `-Dspel.interactive=true` system property to run headed (interactive). Requires *pw* to be bound (use with with-playwright). Binds the Browser instance to *browser*.
Around hook: creates and closes a page.
Requires browser to be bound (use with with-browser). Binds the Page instance to page and allure/page (for automatic step screenshots).
When the Allure reporter is active, automatically enables Playwright tracing (screenshots + DOM snapshots + sources) and HAR recording. Also binds browser-context and browser-api so API calls made through browser-api appear in the Playwright trace. The Allure reporter picks up the trace and HAR files and attaches them to the test result — zero configuration needed in tests.
Around hook: creates and closes a page. Requires *browser* to be bound (use with with-browser). Binds the Page instance to *page* and allure/*page* (for automatic step screenshots). When the Allure reporter is active, automatically enables Playwright tracing (screenshots + DOM snapshots + sources) and HAR recording. Also binds *browser-context* and *browser-api* so API calls made through *browser-api* appear in the Playwright trace. The Allure reporter picks up the trace and HAR files and attaches them to the test result — zero configuration needed in tests.
Around hook: creates and closes a Playwright instance.
Binds the Playwright instance to pw.
Also installs a lightweight try-test-case wrapper that binds
allure/*test-title* from the test case doc string, so trace
groups and step names work even without the Allure reporter.
Around hook: creates and closes a Playwright instance. Binds the Playwright instance to *pw*. Also installs a lightweight try-test-case wrapper that binds `allure/*test-title*` from the test case doc string, so trace groups and step names work even without the Allure reporter.
Around hook: creates a BrowserContext with HAR recording and Playwright tracing enabled, then creates a page from that context.
Requires browser to be bound (use with with-browser). Binds: page — the Page instance allure/page — for automatic step screenshots allure/trace-path — where the trace zip will be written allure/har-path — where the HAR file will be written
On teardown:
The Allure reporter picks up trace-path and har-path and attaches them to the test result automatically.
Around hook: creates a BrowserContext with HAR recording and Playwright
tracing enabled, then creates a page from that context.
Requires *browser* to be bound (use with with-browser).
Binds:
*page* — the Page instance
allure/*page* — for automatic step screenshots
allure/*trace-path* — where the trace zip will be written
allure/*har-path* — where the HAR file will be written
On teardown:
1. Closes page (removes page-level activity)
2. Stops tracing (writes trace.zip, decrements tracingCount)
3. Closes context on a daemon thread with a 5s timeout (writes HAR).
BrowserContextImpl.close() can hang on harExport(NO_TIMEOUT)
when tracing was active on the same context. The daemon thread
approach means: if it completes in time, HAR is written; if it
hangs, the process exits normally and browser.close() cleans up.
The Allure reporter picks up *trace-path* and *har-path* and attaches
them to the test result automatically.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |