test
Integration tests for your application without reverse-engineering its wiring.
The kit boots your own Integrant system on the test profile, keeps cache,
events, realtime and jobs in process, and makes the asynchronous parts
deterministic. Incubating: the API may still change.
Coordinates
Test-only, so it goes in the :test alias:
:test {:extra-deps {com.wagoe/wagoe-test {:mvn/version "1.1.0-rc-1"}}}
Key namespaces
| Namespace | Purpose |
|---|---|
|
The whole kit: test system, Ring client, tenant fixture, job and event helpers. |
Usage
(ns my-app.orders-test
(:require [clojure.test :refer [deftest is]]
[my-app.system-config :as app]
[wagoe.test :as t]))
(deftest placing-an-order
(t/with-test-system [sys app/ig-config]
(let [c (t/client sys)]
(t/sign-in-as! c {:roles [:orders/editor]})
(is (= 201 (:status (t/request c :post "/api/v1/orders" {:json {:sku "x"}}))))
(is (= 1 (t/run-pending-jobs! sys)))
(is (= [:order/placed] (map :type (t/drain-events! sys :orders)))))))
Helpers
| Helper | What it does |
|---|---|
|
Boot your |
|
A Ring client on your handler. Keeps cookies and sends a valid CSRF token with
every POST, PUT, PATCH and DELETE. |
|
Signs in through |
|
Registers a user with |
|
A tenant for the body, deleted with its schema afterwards. Send
|
|
Runs every due job on the test’s thread, including jobs those jobs enqueue. Returns how many ran. |
|
Events published to a topic since the last drain, after every subscriber has handled them. |
|
Realtime envelopes sent since the last drain: |
Both macros bind like let; the jar exports that to clj-kondo.