{"id":32191286,"url":"https://github.com/olecve/react-testing-library-cljs","last_synced_at":"2026-04-01T17:22:03.101Z","repository":{"id":57745148,"uuid":"487996314","full_name":"olecve/react-testing-library-cljs","owner":"olecve","description":"A ClojureScript wrapper for react-testing-library","archived":false,"fork":false,"pushed_at":"2026-03-13T08:42:15.000Z","size":439,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-28T00:37:23.792Z","etag":null,"topics":["clojurescript","react","testing"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olecve.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-05-02T21:30:19.000Z","updated_at":"2026-03-13T08:42:19.000Z","dependencies_parsed_at":"2024-05-27T20:17:06.260Z","dependency_job_id":"1fa0bd7d-1cf6-4517-9dac-64d748810566","html_url":"https://github.com/olecve/react-testing-library-cljs","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"d8686e981d31cd543d422e10023294efacb6eb93"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/olecve/react-testing-library-cljs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olecve%2Freact-testing-library-cljs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olecve%2Freact-testing-library-cljs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olecve%2Freact-testing-library-cljs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olecve%2Freact-testing-library-cljs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olecve","download_url":"https://codeload.github.com/olecve/react-testing-library-cljs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olecve%2Freact-testing-library-cljs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojurescript","react","testing"],"created_at":"2025-10-22T01:36:27.736Z","updated_at":"2026-04-01T17:22:03.076Z","avatar_url":"https://github.com/olecve.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-testing-library-cljs\n\n[![Clojars Project](https://img.shields.io/clojars/v/org.clojars.olecve/react-testing-library-cljs.svg)](https://clojars.org/org.clojars.olecve/react-testing-library-cljs)\n\nThe `react-testing-library-cljs` library provides a ClojureScript functions for the [react-testing-library](https://github.com/testing-library/react-testing-library) to simplify interop.\n\nFor more information about the principles and concepts behind the testing library, you can visit the [official react-testing-library website](https://testing-library.com/).\n\n## Features\n\n### Common\n\n- The `react-testing-library-cljs.screen` namespace provides a wrapper around the `react-testing-library`'s `screen` object, making it easier to interact with rendered components.\n\n- The `react-testing-library-cljs.fire-event` namespace simplifies firing events on rendered components, allowing you to simulate user interactions.\n\n- The `react-testing-library-cljs.within` namespace scopes queries to a specific element, useful when multiple similar elements exist in the DOM.\n\n### Reagent\n\n- The `react-testing-library-cljs.reagent.fire-event` similar to the `react-testing-library-cljs.fire-event`, but calling `reagent.core/flush` after every event to trigger re-render.\n\n- The `react-testing-library-cljs.reagent.render` provides helper function to render reagent components.\n\n## Installation\n\nAdd the library to your project:\n\n### deps.edn\n\n```clojure\norg.clojars.olecve/react-testing-library-cljs {:mvn/version \"0.0.16\"}\n```\n\n### Leiningen\n\n```clojure\n[org.clojars.olecve/react-testing-library-cljs \"0.0.16\"]\n```\n\nInstall the npm dependency:\n\n```bash\nnpm install --save-dev @testing-library/react\n```\n\n### shadow-cljs config\n\nAdd a `:node-test` build target:\n\n```clojure\n;; shadow-cljs.edn\n{:builds\n {:test {:target :node-test\n         :output-to \"out/test.js\"}}}\n```\n\nRun tests with:\n\n```bash\nnpx shadow-cljs compile test \u0026\u0026 node --require global-jsdom/register out/test.js\n```\n\n## Usage\n\n### Rendering \u0026 querying\n\n```clojure\n(ns my-app.core-test\n  (:require [cljs.test :refer [deftest is]]\n            [react-testing-library-cljs.reagent.render :as render]\n            [react-testing-library-cljs.screen :as screen]))\n\n(defn greeting []\n  [:h1 \"Hello, world!\"])\n\n(deftest renders-greeting\n  (render/render! [greeting])\n  (is (some? (screen/get-by-text \"Hello, world!\"))))\n```\n\n### Firing events\n\n```clojure\n(ns my-app.events-test\n  (:require [cljs.test :refer [deftest is]]\n            [react-testing-library-cljs.reagent.render :as render]\n            [react-testing-library-cljs.reagent.fire-event :as fire-event]\n            [react-testing-library-cljs.screen :as screen]\n            [reagent.core :as r]))\n\n(defn counter []\n  (let [count (r/atom 0)]\n    (fn []\n      [:button {:on-click #(swap! count inc)}\n       (str \"Count: \" @count)])))\n\n(deftest click-increments-counter\n  (render/render! [counter])\n  (render/act #(fire-event/click (screen/get-by-text \"Count: 0\")))\n  (is (screen/get-by-text \"Count: 1\")))\n```\n\n### Mocks\n\n```clojure\n(ns my-app.mocks-test\n  (:require [cljs.test :refer [deftest is]]\n            [react-testing-library-cljs.mocks :as mocks]\n            [react-testing-library-cljs.reagent.render :as render]\n            [react-testing-library-cljs.fire-event :as fire-event]\n            [react-testing-library-cljs.screen :as screen]))\n\n(deftest tracks-button-click\n  (let [[calls on-click] (mocks/create)]\n    (render/render! [:button {:on-click on-click} \"Submit\"])\n    (fire-event/click (screen/get-by-text \"Submit\"))\n    (is (= 1 (count @calls)))))\n```\n\n### Scoped queries with `within`\n\nUse `within` to scope queries to a subtree — useful when the same elements appear in multiple places.\nIn the example below, scoping to the dialog avoids ambiguity with other \"Delete\" buttons on the page:\n\n```clojure\n(ns my-app.within-test\n  (:require [cljs.test :refer [deftest is]]\n            [react-testing-library-cljs.reagent.render :as render]\n            [react-testing-library-cljs.screen :as screen]\n            [react-testing-library-cljs.within :as within]))\n\n(defn page []\n  [:div\n   [:ul\n    [:li \"Report Q4\" [:button \"Delete\"]]\n    [:li \"Report Q3\" [:button \"Delete\"]]]\n   [:div {:role \"dialog\" :aria-label \"Confirm deletion\"}\n    [:p \"Are you sure you want to delete this report?\"]\n    [:button \"Delete\"]\n    [:button \"Cancel\"]]])\n\n(deftest confirm-dialog-has-correct-actions\n  (render/render! [page])\n  (let [dialog (screen/get-by-role \"dialog\")]\n    (is (some? (within/get-by-role dialog \"button\" {:name \"Delete\"})))\n    (is (some? (within/get-by-role dialog \"button\" {:name \"Cancel\"})))))\n```\n\n### Async queries\n\n`find-by-*` queries return a promise that resolves when a matching element appears (useful for async updates):\n\n```clojure\n(ns my-app.async-test\n  (:require [cljs.test :refer [deftest async is]]\n            [react-testing-library-cljs.reagent.render :as render]\n            [react-testing-library-cljs.screen :as screen]))\n\n(deftest finds-async-element\n  (async done\n    (render/render! [my-async-component])\n    (-\u003e (screen/find-by-text \"Loaded!\")\n        (.then (fn [element]\n                 (is (some? element))\n                 (done))))))\n```\n\n## Release\n\nPrerequisites:\n\n- GPG configured ([lein help gpg](https://github.com/technomancy/leiningen/blob/stable/doc/GPG.md))\n- Clojars credentials in `~/.lein/profiles.clj`:\n\n```clojure\n{:auth {:repository-auth {#\"clojars\" {:username \"USERNAME\" :password \"CLOJARS_TOKEN\"}}}}\n```\n\nRun:\n\n```bash\nbb release\n```\n\n## LICENSE\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folecve%2Freact-testing-library-cljs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folecve%2Freact-testing-library-cljs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folecve%2Freact-testing-library-cljs/lists"}