cljs-tlr.uix
UIx-specific testing utilities.
Provides convenience functions for rendering UIx components in tests. UIx components compile to React elements, so they work directly with testing-library, but these helpers make common patterns more ergonomic.
render
(render element)(render element opts)Renders a UIx component and returns query utilities.
This is identical to cljs-tlr.render/render but serves as documentation that UIx components work directly with testing-library.
Example:
(ns my-app.button-test
(:require
[cljs.test :as t :include-macros true]
[cljs-tlr.uix :as uix-tlr]
[cljs-tlr.screen :as screen]
[cljs-tlr.fixtures :as fixtures]
[uix.core :refer [$ defui]]))
(defui button [{:keys [on-click children]}]
($ :button {:on-click on-click} children))
(t/use-fixtures :each fixtures/cleanup-fixture)
(t/deftest button-renders-children-test
(uix-tlr/render ($ button {} "Click me"))
(t/is (some? (screen/get-by-role "button" {:name "Click me"}))))
render-with-wrapper
(render-with-wrapper element wrapper-opts)Renders a UIx component wrapped in a context provider.
The wrapper-component should be a UIx component that accepts children. This is useful for providing React Context to components under test.
Example:
(defui theme-provider [{:keys [theme children]}]
($ ThemeContext.Provider {:value theme} children))
(render-with-wrapper
($ my-themed-button)
{:wrapper (fn [props]
($ theme-provider {:theme "dark"}
(.-children props)))})
setup-user
(setup-user)(setup-user opts)Creates a user-event instance configured for UIx testing.
This is a convenience wrapper around cljs-tlr.user-event/setup with sensible defaults for UIx component testing.
Returns a user object for interaction functions.