Liking cljdoc? Tell your friends :D

com.blockether.spel.allure

In-test Allure API for enriching test reports with steps, metadata, screenshots, and attachments.

All functions are no-ops when *context* is nil, meaning they are safe to call even when not running under the Allure reporter.

Usage in tests:

(ns my-app.login-test (:require [com.blockether.spel.allure :as allure] [com.blockether.spel.page :as page] [com.blockether.spel.locator :as locator]))

(defdescribe login-flow (allure/epic "Authentication") (allure/feature "Login") (allure/severity :critical)

 (it "logs in with valid credentials"
   (allure/step "Navigate to login page"
     (page/navigate page "https://example.com/login"))
   (allure/step "Enter credentials"
     (allure/parameter "username" "admin")
     (locator/fill (locator/locator page "#username") "admin")
     (locator/fill (locator/locator page "#password") "secret"))
   (allure/step "Submit and verify"
     (locator/click (locator/locator page "button[type=submit]"))
     (allure/screenshot page "After login"))))
In-test Allure API for enriching test reports with steps, metadata,
screenshots, and attachments.

All functions are no-ops when `*context*` is nil, meaning they are
safe to call even when not running under the Allure reporter.

 Usage in tests:

   (ns my-app.login-test
     (:require [com.blockether.spel.allure :as allure]
               [com.blockether.spel.page :as page]
               [com.blockether.spel.locator :as locator]))

   (defdescribe login-flow
     (allure/epic "Authentication")
     (allure/feature "Login")
     (allure/severity :critical)

     (it "logs in with valid credentials"
       (allure/step "Navigate to login page"
         (page/navigate page "https://example.com/login"))
       (allure/step "Enter credentials"
         (allure/parameter "username" "admin")
         (locator/fill (locator/locator page "#username") "admin")
         (locator/fill (locator/locator page "#password") "secret"))
       (allure/step "Submit and verify"
         (locator/click (locator/locator page "button[type=submit]"))
         (allure/screenshot page "After login"))))
raw docstring

*context*clj

Dynamic var holding the current test's Allure context atom during execution. Bound by the reporter's wrap-try-test-case. nil when not running under the Allure reporter.

The atom contains: {:labels [{:name "epic" :value "Auth"} ...] :links [{:name "BUG-1" :url "..." :type "issue"} ...] :parameters [{:name "browser" :value "chromium"} ...] :attachments [{:name "screenshot" :source "uuid.png" :type "image/png"} ...] :steps [] ;; completed top-level steps :step-stack [] ;; stack for nesting (open steps in progress) :description nil} ;; markdown description

Dynamic var holding the current test's Allure context atom during
execution. Bound by the reporter's `wrap-try-test-case`. nil when
not running under the Allure reporter.

The atom contains:
  {:labels       [{:name "epic" :value "Auth"} ...]
   :links        [{:name "BUG-1" :url "..." :type "issue"} ...]
   :parameters   [{:name "browser" :value "chromium"} ...]
   :attachments  [{:name "screenshot" :source "uuid.png" :type "image/png"} ...]
   :steps        []   ;; completed top-level steps
   :step-stack   []   ;; stack for nesting (open steps in progress)
   :description  nil} ;; markdown description
sourceraw docstring

*har-path*clj

Dynamic var holding the java.io.File where the HAR (HTTP Archive) will be written. Bound by with-traced-page. The HAR is written when the BrowserContext closes. The Allure reporter captures this path and attaches the HAR file as a download link after the test completes. When nil (default), no HAR is captured.

Dynamic var holding the java.io.File where the HAR (HTTP Archive)
will be written. Bound by `with-traced-page`. The HAR is written
when the BrowserContext closes. The Allure reporter captures this
path and attaches the HAR file as a download link after the test
completes. When nil (default), no HAR is captured.
sourceraw docstring

*output-dir*clj

Dynamic var holding the allure-results output directory (java.io.File). Bound by the reporter alongside context.

Dynamic var holding the allure-results output directory (java.io.File).
Bound by the reporter alongside *context*.
sourceraw docstring

*page*clj

Dynamic var holding the current Playwright Page instance for automatic step screenshots. When non-nil, every lambda step automatically captures a "Post: <step>" screenshot after execution. Bind alongside the test-fixtures *page*:

(binding [allure/page page] (f))

When nil (default), no automatic screenshots are taken.

Dynamic var holding the current Playwright Page instance for automatic
 step screenshots. When non-nil, every lambda step automatically captures
 a "Post: <step>" screenshot after execution. Bind alongside the
 test-fixtures `*page*`:

  (binding [allure/*page* page] (f))

When nil (default), no automatic screenshots are taken.
sourceraw docstring

*test-err*clj

Dynamic var holding the test-level Writer for stderr accumulation. Same as test-out but for err.

Dynamic var holding the test-level Writer for stderr accumulation.
Same as *test-out* but for *err*.
sourceraw docstring

*test-out*clj

Dynamic var holding the test-level Writer for stdout accumulation. Bound by the reporter's wrap-try-test-case to a per-test StringWriter. Step capture tees to this so stdout flows to both the step attachment AND the test-level system-out.

Dynamic var holding the test-level Writer for stdout accumulation.
Bound by the reporter's `wrap-try-test-case` to a per-test
StringWriter. Step capture tees to this so stdout flows to both
the step attachment AND the test-level system-out.
sourceraw docstring

*test-title*clj

Dynamic var holding the current test's display title. Bound by the reporter's wrap-try-test-case to the test case identifier (e.g. "captures screenshot and attaches to report"). Used by test fixtures for the Playwright trace title.

Dynamic var holding the current test's display title.
Bound by the reporter's `wrap-try-test-case` to the test case
identifier (e.g. "captures screenshot and attaches to report").
Used by test fixtures for the Playwright trace title.
sourceraw docstring

*trace-path*clj

Dynamic var holding the java.io.File where the Playwright trace zip will be written. Bound by with-traced-page. The Allure reporter captures this path and attaches the trace file (with MIME type application/vnd.allure.playwright-trace) after the test completes. When nil (default), no trace is captured.

Dynamic var holding the java.io.File where the Playwright trace zip
will be written. Bound by `with-traced-page`. The Allure reporter
captures this path and attaches the trace file (with MIME type
application/vnd.allure.playwright-trace) after the test completes.
When nil (default), no trace is captured.
sourceraw docstring

*tracing*clj

Dynamic var holding the current Playwright Tracing object. Bound by test fixtures (with-page, with-traced-page, with-api-tracing) when tracing is active. When bound, step* automatically calls tracing.group()/groupEnd() so steps appear as groups in the Playwright Trace Viewer.

Dynamic var holding the current Playwright Tracing object.
Bound by test fixtures (with-page, with-traced-page, with-api-tracing)
when tracing is active. When bound, `step*` automatically calls
tracing.group()/groupEnd() so steps appear as groups in the
Playwright Trace Viewer.
sourceraw docstring

aftercljmacro

(after & body)

Re-export of lazytest.core/after. Runs body once after all nested suites and test cases.

Re-export of `lazytest.core/after`.
Runs body once after all nested suites and test cases.
sourceraw docstring

after-eachcljmacro

(after-each & body)

Re-export of lazytest.core/after-each. Runs body after each nested test case.

Re-export of `lazytest.core/after-each`.
Runs body after each nested test case.
sourceraw docstring

api-stepcljmacro

(api-step step-name & body)

Execute an API step with automatic request/response logging.

Wraps the body in an allure step. If the body returns a Playwright APIResponse, automatically attaches status, url, content-type as parameters and the response body as an attachment to the report.

Usage:

(allure/api-step "Create user" (api/api-post ctx "/users" {:data "{"name": "Alice"}" :headers {"Content-Type" "application/json"}}))

;; Parameters in report: ;; status → 201 ;; url → https://api.example.com/users ;; ok? → true ;; content-type → application/json ;; Attachment: ;; Response Body (application/json)

Works with any expression — only attaches metadata when the result is an APIResponse instance. No-op when not running under the Allure reporter.

Execute an API step with automatic request/response logging.

Wraps the body in an allure step. If the body returns a Playwright
APIResponse, automatically attaches status, url, content-type as
parameters and the response body as an attachment to the report.

Usage:

  (allure/api-step "Create user"
    (api/api-post ctx "/users"
      {:data "{\"name\": \"Alice\"}"
       :headers {"Content-Type" "application/json"}}))

  ;; Parameters in report:
  ;;   status       → 201
  ;;   url          → https://api.example.com/users
  ;;   ok?          → true
  ;;   content-type → application/json
  ;; Attachment:
  ;;   Response Body (application/json)

Works with any expression — only attaches metadata when the result
is an APIResponse instance. No-op when not running under the Allure
reporter.
sourceraw docstring

aroundcljmacro

(around [f] & body)

Re-export of lazytest.core/around. Wraps nested execution in a function, useful for binding forms.

Re-export of `lazytest.core/around`.
Wraps nested execution in a function, useful for `binding` forms.
sourceraw docstring

attachclj

(attach att-name content content-type)

Attach string content to the test report. content-type is a MIME type, e.g. "text/plain", "application/json".

Attach string content to the test report.
`content-type` is a MIME type, e.g. "text/plain", "application/json".
sourceraw docstring

attach-api-response!clj

(attach-api-response! resp)

Attach APIResponse metadata to the current allure step as parameters, attachments, and console log output. Safe — swallows all errors.

Captures:

  • Parameters: status, status-text, url, ok?, content-type, content-length
  • Attachments: "Response Headers" (full HTTP header block), "Response Body" (pretty-printed JSON, raw XML/HTML/text)
  • Console log: status line, url, content-type, body preview (shows as ⏵ marker sub-steps in the Allure report)

This function is public because it is referenced by the api-step macro which expands in the calling namespace.

Attach APIResponse metadata to the current allure step as parameters,
attachments, and console log output. Safe — swallows all errors.

Captures:
  - Parameters:  status, status-text, url, ok?, content-type, content-length
  - Attachments: "Response Headers" (full HTTP header block),
                 "Response Body" (pretty-printed JSON, raw XML/HTML/text)
  - Console log: status line, url, content-type, body preview
                 (shows as ⏵ marker sub-steps in the Allure report)

This function is public because it is referenced by the `api-step` macro
which expands in the calling namespace.
sourceraw docstring

attach-bytesclj

(attach-bytes att-name bytes content-type)

Attach binary content to the test report. content-type is a MIME type, e.g. "image/png", "application/pdf".

Attach binary content to the test report.
`content-type` is a MIME type, e.g. "image/png", "application/pdf".
sourceraw docstring

beforecljmacro

(before & body)

Re-export of lazytest.core/before. Runs body once before all nested suites and test cases.

Re-export of `lazytest.core/before`.
Runs body once before all nested suites and test cases.
sourceraw docstring

before-eachcljmacro

(before-each & body)

Re-export of lazytest.core/before-each. Runs body before each nested test case.

Re-export of `lazytest.core/before-each`.
Runs body before each nested test case.
sourceraw docstring

causes-with-msg?clj

(causes-with-msg? c re f)

Re-export of lazytest.core/causes-with-msg?. Calls f with no arguments; returns true if any exception in the cause chain is an instance of class c with a message matching re.

Re-export of `lazytest.core/causes-with-msg?`.
Calls f with no arguments; returns true if any exception in the
cause chain is an instance of class c with a message matching re.
sourceraw docstring

causes?clj

(causes? c f)

Re-export of lazytest.core/causes?. Calls f with no arguments; returns true if any exception in the cause chain is an instance of class c.

Re-export of `lazytest.core/causes?`.
Calls f with no arguments; returns true if any exception in the
cause chain is an instance of class c.
sourceraw docstring

contextcljmacro

(context doc & children)
(context doc attr-map? & children)

Alias for describe — includes automatic Allure step nesting.

Alias for `describe` — includes automatic Allure step nesting.
sourceraw docstring

defdescribecljmacro

(defdescribe test-name & children)
(defdescribe test-name doc? attr-map? & children)

Re-export of lazytest.core/defdescribe. Defines a top-level test suite var.

Does not create an Allure step — the defdescribe name is already visible as the top-level suite label in the report.

Re-export of `lazytest.core/defdescribe`.
Defines a top-level test suite var.

Does not create an Allure step — the defdescribe name is already
visible as the top-level suite label in the report.
sourceraw docstring

describecljmacro

(describe doc & children)
(describe doc attr-map? & children)

Like lazytest.core/describe with automatic Allure step nesting.

Injects an around hook so each test case executed within this suite is wrapped in an Allure step named after the doc string. Nested describes produce nested steps.

When not running under the Allure reporter, the step call is a no-op — just (f) — so there is zero runtime overhead.

Like `lazytest.core/describe` with automatic Allure step nesting.

Injects an `around` hook so each test case executed within this
suite is wrapped in an Allure step named after the doc string.
Nested describes produce nested steps.

When not running under the Allure reporter, the step call is a
no-op — just `(f)` — so there is zero runtime overhead.
sourceraw docstring

descriptionclj

(description text)

Set the test description (markdown supported).

Set the test description (markdown supported).
sourceraw docstring

epicclj

(epic value)

Set the epic label for this test.

Set the epic label for this test.
sourceraw docstring

expectcljmacro

(expect expr)
(expect expr msg)

Drop-in replacement for lazytest.core/expect that automatically creates an Allure step for each expectation.

When running under the Allure reporter, each expect call renders as a named step in the report with its own pass/fail status. The step name is derived from the source expression (or the custom message when provided).

When not running under the Allure reporter, delegates directly to lazytest.core/expect with zero overhead.

With custom message:

(expect (= 1 1) "numbers are equal") ;; Step name: "expect: numbers are equal"

Drop-in replacement for `lazytest.core/expect` that automatically
creates an Allure step for each expectation.

When running under the Allure reporter, each `expect` call renders
as a named step in the report with its own pass/fail status. The
step name is derived from the source expression (or the custom
message when provided).

When not running under the Allure reporter, delegates directly to
`lazytest.core/expect` with zero overhead.

With custom message:

  (expect (= 1 1) "numbers are equal")
  ;; Step name: "expect: numbers are equal"
sourceraw docstring

expect-itcljmacro

(expect-it doc expr)
(expect-it doc attr-map? expr)

Like lazytest.core/expect-it with stepped expectations. Shorthand for (it doc (expect expr)).

Uses lt-core/it directly (no extra it-level step) since expect-it has exactly one assertion — the expect step is sufficient.

Like `lazytest.core/expect-it` with stepped expectations.
Shorthand for `(it doc (expect expr))`.

Uses `lt-core/it` directly (no extra it-level step) since
expect-it has exactly one assertion — the expect step is
sufficient.
sourceraw docstring

featureclj

(feature value)

Set the feature label for this test.

Set the feature label for this test.
sourceraw docstring

issueclj

(issue name url)

Add an issue link.

Add an issue link.
sourceraw docstring

itcljmacro

(it doc & body)
(it doc attr-map? & body)

Like lazytest.core/it with automatic Allure step wrapping.

Wraps the test body in an Allure step named after the doc string, providing a named container for the expect steps within.

When not running under the Allure reporter, the step call is a no-op — just (body) — so there is zero runtime overhead.

Like `lazytest.core/it` with automatic Allure step wrapping.

Wraps the test body in an Allure step named after the doc string,
providing a named container for the expect steps within.

When not running under the Allure reporter, the step call is a
no-op — just `(body)` — so there is zero runtime overhead.
sourceraw docstring

(link name url)

Add a link to the test report.

Add a link to the test report.
sourceraw docstring

make-contextclj

(make-context)

Create a fresh context map for a test case. Called by the reporter.

Create a fresh context map for a test case. Called by the reporter.
sourceraw docstring

ok?clj

(ok? f)

Re-export of lazytest.core/ok?. Calls f with no arguments and discards its return value. Returns true if f does not throw. Useful for expressions that return false.

Re-export of `lazytest.core/ok?`.
Calls f with no arguments and discards its return value. Returns
true if f does not throw. Useful for expressions that return false.
sourceraw docstring

ownerclj

(owner value)

Set the test owner.

Set the test owner.
sourceraw docstring

parameterclj

(parameter name value)

Add a parameter to the test or current step.

Add a parameter to the test or current step.
sourceraw docstring

reporter-active?clj

(reporter-active?)

Returns true when the Allure reporter is active (i.e. we're generating a report). Fixtures use this to auto-enable tracing.

Returns true when the Allure reporter is active (i.e. we're
generating a report). Fixtures use this to auto-enable tracing.
sourceraw docstring

screenshotclj

(screenshot pg att-name)

Take a Playwright screenshot and attach it to the report. pg is a Playwright Page instance. att-name is the display name.

Take a Playwright screenshot and attach it to the report.
`pg` is a Playwright Page instance. `att-name` is the display name.
sourceraw docstring

set-ns-context!clj

(set-ns-context! contexts)

Re-export of lazytest.core/set-ns-context!. Add hooks to the namespace suite, instead of to a var or test suite.

Re-export of `lazytest.core/set-ns-context!`.
Add hooks to the namespace suite, instead of to a var or test suite.
sourceraw docstring

set-reporter-active!clj

(set-reporter-active! active?)

Called by the Allure reporter at begin/end of test run.

Called by the Allure reporter at begin/end of test run.
sourceraw docstring

severityclj

(severity level)

Set the severity label. Level should be one of: :blocker :critical :normal :minor :trivial

Set the severity label. Level should be one of:
:blocker :critical :normal :minor :trivial
sourceraw docstring

shouldcljmacro

(should expr)
(should expr msg)

Like lazytest.core/should with stepped expectations. Alias for expect.

Like `lazytest.core/should` with stepped expectations.
Alias for `expect`.
sourceraw docstring

specifycljmacro

(specify doc & body)
(specify doc attr-map? & body)

Alias for it — includes automatic Allure step wrapping.

Alias for `it` — includes automatic Allure step wrapping.
sourceraw docstring

stepcljmacro

(step step-name)
(step step-name & body)

Add a step to the test report.

Two arities:

  • (step name) — marker step (checkpoint, no body)
  • (step name & body) — lambda step (executes body, timed, nestable)

Steps can nest arbitrarily:

(allure/step "Login" (allure/step "Enter username" (locator/fill username-input "admin")) (allure/step "Enter password" (locator/fill password-input "secret")) (allure/step "Click submit" (locator/click submit-btn)))

All step calls are no-ops when not running under the Allure reporter.

When Playwright tracing is active, the step's source location is captured at macro expansion time (via *file* and &form metadata) and passed to Tracing.group(name, GroupOptions) so the Trace Viewer links to the test source file instead of allure.clj internals.

Add a step to the test report.

Two arities:
- (step name)              — marker step (checkpoint, no body)
- (step name & body)       — lambda step (executes body, timed, nestable)

Steps can nest arbitrarily:

  (allure/step "Login"
    (allure/step "Enter username"
      (locator/fill username-input "admin"))
    (allure/step "Enter password"
      (locator/fill password-input "secret"))
    (allure/step "Click submit"
      (locator/click submit-btn)))

All step calls are no-ops when not running under the Allure reporter.

When Playwright tracing is active, the step's source location is
captured at macro expansion time (via `*file*` and `&form` metadata)
and passed to `Tracing.group(name, GroupOptions)` so the Trace Viewer
links to the test source file instead of allure.clj internals.
sourceraw docstring

step*clj

(step* step-name)
(step* step-name f)
(step* step-name f loc-map)

Internal function backing the step macro. Prefer the macro.

Three arities:

  • (step* name) — marker step (records a named checkpoint, no body)
  • (step* name f) — lambda step (executes f, records timing and status)
  • (step* name f loc-map) — lambda step with source location override for Playwright Trace Viewer (loc-map = {:file ... :line ...})

Does NOT take screenshots. Use ui-step for steps that need before/after screenshots, or call screenshot explicitly.

Internal function backing the `step` macro. Prefer the macro.

Three arities:
- (step* name)              — marker step (records a named checkpoint, no body)
- (step* name f)            — lambda step (executes f, records timing and status)
- (step* name f loc-map)    — lambda step with source location override for
                               Playwright Trace Viewer (loc-map = {:file ... :line ...})

Does NOT take screenshots. Use `ui-step` for steps that need
before/after screenshots, or call `screenshot` explicitly.
sourceraw docstring

storyclj

(story value)

Set the story label for this test.

Set the story label for this test.
sourceraw docstring

tagclj

(tag value)

Add a tag label.

Add a tag label.
sourceraw docstring

throws-with-msg?clj

(throws-with-msg? c re f)

Re-export of lazytest.core/throws-with-msg?. Calls f with no arguments; catches exceptions of class c. Returns true if the exception message matches the regex re.

Re-export of `lazytest.core/throws-with-msg?`.
Calls f with no arguments; catches exceptions of class c. Returns
true if the exception message matches the regex re.
sourceraw docstring

throws?clj

(throws? c f)

Re-export of lazytest.core/throws?. Calls f with no arguments; returns true if it throws an instance of class c. Any other exception will be re-thrown.

Re-export of `lazytest.core/throws?`.
Calls f with no arguments; returns true if it throws an instance of
class c. Any other exception will be re-thrown.
sourceraw docstring

tmsclj

(tms name url)

Add a test management system link.

Add a test management system link.
sourceraw docstring

ui-stepcljmacro

(ui-step step-name & body)

Execute a UI step with automatic before/after screenshots.

Creates a parent step with two nested child steps:

  • "Before: <name>" — screenshot captured before the action
  • "After: <name>" — screenshot captured after the action

Requires *page* to be bound (typically done by the reporter's with-traced-page or test fixtures).

When Playwright tracing is active (*trace-path* is bound), the explicit screenshots are skipped — the trace already captures visual state on every action, so the screenshots would only add noise to the trace timeline without providing additional value.

The step hierarchy in the Allure report (without tracing):

✓ Login to application ├── Before: Login to application (screenshot) ├── ... (your actions) └── After: Login to application (screenshot)

Usage:

(allure/ui-step "Fill login form" (locator/fill username-input "admin") (locator/fill password-input "secret") (locator/click submit-btn))

Falls back to a regular step when *page* is not bound. No-op when not running under the Allure reporter.

Execute a UI step with automatic before/after screenshots.

Creates a parent step with two nested child steps:
- "Before: <name>" — screenshot captured before the action
- "After: <name>"  — screenshot captured after the action

Requires `*page*` to be bound (typically done by the reporter's
`with-traced-page` or test fixtures).

When Playwright tracing is active (`*trace-path*` is bound), the
explicit screenshots are skipped — the trace already captures visual
state on every action, so the screenshots would only add noise to
the trace timeline without providing additional value.

The step hierarchy in the Allure report (without tracing):

  ✓ Login to application
    ├── Before: Login to application (screenshot)
    ├── ... (your actions)
    └── After: Login to application  (screenshot)

Usage:

  (allure/ui-step "Fill login form"
    (locator/fill username-input "admin")
    (locator/fill password-input "secret")
    (locator/click submit-btn))

Falls back to a regular step when `*page*` is not bound.
No-op when not running under the Allure reporter.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close