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.
(browser-engine)Returns the browser engine keyword to launch.
Checks system property spel.browser first, then env var SPEL_BROWSER.
Returns :chromium when unset. Supported: :chromium, :firefox, :webkit.
Usage: clojure -J-Dspel.browser=firefox -M:test SPEL_BROWSER=webkit clojure -M:test
Returns the browser engine keyword to launch. Checks system property `spel.browser` first, then env var `SPEL_BROWSER`. Returns :chromium when unset. Supported: :chromium, :firefox, :webkit. Usage: clojure -J-Dspel.browser=firefox -M:test SPEL_BROWSER=webkit clojure -M:test
(ct-fixture around-hook)Extract the underlying function from a Lazytest around hook.
Lazytest around hooks are maps {:around fn}. clojure.test needs plain functions. This helper extracts the :around fn so you can use Lazytest fixtures with clojure.test/use-fixtures:
(use-fixtures :once (ct-fixture with-playwright) (ct-fixture with-browser)) (use-fixtures :each (ct-fixture with-traced-page) with-allure-context)
Extract the underlying function from a Lazytest around hook.
Lazytest around hooks are maps {:around fn}. clojure.test needs plain
functions. This helper extracts the :around fn so you can use Lazytest
fixtures with clojure.test/use-fixtures:
(use-fixtures :once (ct-fixture with-playwright) (ct-fixture with-browser))
(use-fixtures :each (ct-fixture with-traced-page) with-allure-context)(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
(slow-mo)Returns the slow-mo delay in milliseconds for browser actions.
Checks system property spel.slow-mo first, then env var SPEL_SLOW_MO.
Returns 0 when unset. Useful for watching tests step-by-step in headed mode.
Usage: clojure -J-Dspel.slow-mo=500 -J-Dspel.interactive=true -M:test SPEL_SLOW_MO=500 SPEL_INTERACTIVE=true clojure -M:test
Returns the slow-mo delay in milliseconds for browser actions. Checks system property `spel.slow-mo` first, then env var `SPEL_SLOW_MO`. Returns 0 when unset. Useful for watching tests step-by-step in headed mode. Usage: clojure -J-Dspel.slow-mo=500 -J-Dspel.interactive=true -M:test SPEL_SLOW_MO=500 SPEL_INTERACTIVE=true clojure -M:test
Around hook: creates a BrowserContext with Playwright tracing for API-only tests (no page needed).
Configuration via system properties / env vars: spel.interactive / SPEL_INTERACTIVE — headed mode (default: headless) spel.slow-mo / SPEL_SLOW_MO — action delay in ms (default: 0) spel.browser / SPEL_BROWSER — engine: chromium|firefox|webkit (default: chromium)
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).
Configuration via system properties / env vars:
spel.interactive / SPEL_INTERACTIVE — headed mode (default: headless)
spel.slow-mo / SPEL_SLOW_MO — action delay in ms (default: 0)
spel.browser / SPEL_BROWSER — engine: chromium|firefox|webkit (default: chromium)
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 browser.
Configuration via system properties / env vars: spel.interactive / SPEL_INTERACTIVE — headed mode (default: headless) spel.slow-mo / SPEL_SLOW_MO — action delay in ms (default: 0) spel.browser / SPEL_BROWSER — engine: chromium|firefox|webkit (default: chromium)
Requires pw to be bound (use with with-playwright). Binds the Browser instance to browser.
Around hook: launches and closes a browser. Configuration via system properties / env vars: spel.interactive / SPEL_INTERACTIVE — headed mode (default: headless) spel.slow-mo / SPEL_SLOW_MO — action delay in ms (default: 0) spel.browser / SPEL_BROWSER — engine: chromium|firefox|webkit (default: chromium) Requires *pw* to be bound (use with with-playwright). Binds the Browser instance to *browser*.
Around hook: creates and closes a page (default — no context opts).
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.
To pass context-opts (viewport, locale, etc.), use with-page-opts instead.
Around hook: creates and closes a page (default — no context opts). 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. To pass context-opts (viewport, locale, etc.), use `with-page-opts` instead.
(with-page-opts context-opts)Like with-page but accepts context-opts for the BrowserContext.
Returns a Lazytest around hook that creates a BrowserContext with the given opts merged in, then creates a page from that context.
Context opts support all Browser$NewContextOptions keys:
:locale, :viewport, :color-scheme, :storage-state,
:user-agent, :timezone-id, :permissions, etc.
Usage: {:context [with-playwright with-browser (with-page-opts {:locale "fr-FR" :viewport {:width 375 :height 812}})]}
HAR recording opts are set automatically when the Allure reporter is active.
Like `with-page` but accepts context-opts for the BrowserContext.
Returns a Lazytest around hook that creates a BrowserContext with the
given opts merged in, then creates a page from that context.
Context opts support all Browser$NewContextOptions keys:
`:locale`, `:viewport`, `:color-scheme`, `:storage-state`,
`:user-agent`, `:timezone-id`, `:permissions`, etc.
Usage:
{:context [with-playwright with-browser (with-page-opts {:locale "fr-FR"
:viewport {:width 375 :height 812}})]}
HAR recording opts are set automatically when the Allure reporter is active.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 (default — no context opts).
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.
To pass context-opts (viewport, locale, etc.), use with-traced-page-opts instead.
Around hook: creates a BrowserContext with HAR recording and Playwright tracing enabled, then creates a page from that context (default — no context opts). 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). The Allure reporter picks up *trace-path* and *har-path* and attaches them to the test result automatically. To pass context-opts (viewport, locale, etc.), use `with-traced-page-opts` instead.
(with-traced-page-opts context-opts)Like with-traced-page but accepts context-opts for the BrowserContext.
Returns a Lazytest around hook that creates a BrowserContext with the given opts merged in, HAR recording, and Playwright tracing enabled.
Context opts support all Browser$NewContextOptions keys:
:locale, :viewport, :color-scheme, :storage-state,
:user-agent, :timezone-id, :permissions, etc.
HAR recording opts (:record-har-path, :record-har-mode) are always
set by this hook — user opts are merged first, then HAR opts overlay.
Usage: {:context [with-playwright with-browser (with-traced-page-opts {:locale "fr-FR" :viewport {:width 375 :height 812}})]}
The Allure reporter picks up trace-path and har-path and attaches them to the test result automatically.
Like `with-traced-page` but accepts context-opts for the BrowserContext.
Returns a Lazytest around hook that creates a BrowserContext with the
given opts merged in, HAR recording, and Playwright tracing enabled.
Context opts support all Browser$NewContextOptions keys:
`:locale`, `:viewport`, `:color-scheme`, `:storage-state`,
`:user-agent`, `:timezone-id`, `:permissions`, etc.
HAR recording opts (`:record-har-path`, `:record-har-mode`) are always
set by this hook — user opts are merged first, then HAR opts overlay.
Usage:
{:context [with-playwright with-browser (with-traced-page-opts {:locale "fr-FR"
:viewport {:width 375 :height 812}})]}
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 |