Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
example: [reagent-karma-example, node-test-example]
example: [reagent-karma-example, node-test-example, re-frame-example]
defaults:
run:
working-directory: examples/${{ matrix.example }}
Expand Down
4 changes: 4 additions & 0 deletions examples/re-frame-example/.clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
;; `await` is the native ClojureScript async operator (cljs >= 1.12.145).
;; The clj-kondo release on npm does not recognize it yet, so silence the
;; unresolved-symbol warning for it here.
{:linters {:unresolved-symbol {:exclude [await]}}}
7 changes: 7 additions & 0 deletions examples/re-frame-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
/out
/target
/.shadow-cljs
/.cpcache
/.clj-kondo/.cache
/.clj-kondo/imports
5 changes: 5 additions & 0 deletions examples/re-frame-example/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
out
target
.shadow-cljs
.cpcache
3 changes: 3 additions & 0 deletions examples/re-frame-example/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["prettier-plugin-cljfmt"]
}
33 changes: 33 additions & 0 deletions examples/re-frame-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# re-frame-example

An example of testing a [re-frame](https://github.com/day8/re-frame) app with
[`react-testing-library-cljs`](https://github.com/olecve/react-testing-library-cljs),
using shadow-cljs's `:node-test` target and jsdom — no browser required.

## What it demonstrates

- **`app.events-test`** — unit-testing re-frame event and subscription handlers
as plain functions (the recommended re-frame pattern), with no DOM.
- **`app.views-test`** — testing a re-frame view with the library:
- rendering it and reading the DOM with `screen`,
- reacting to a synchronous `dispatch-sync` (wrapped in `act`),
- driving state through a real click and waiting for the async re-frame
`dispatch` to reach the DOM via `find-by-text`.

## Setup essentials

- `shadow-cljs.edn` declares `reagent` and `re-frame` as dependencies and a
`:node-test` build with an `app.test-setup` preload. It references the
library's source in this repo via `:source-paths` (so the example always
tracks HEAD); a standalone project would add the Clojars dependency instead —
see the repository root README.
- `src/app/test_setup.cljs` registers jsdom and sets `IS_REACT_ACT_ENVIRONMENT`.

## Running

```bash
npm install
npm test # compile the :test build and run it on Node
npm run lint # clj-kondo
npm run fmt # prettier + cljfmt
```
Loading
Loading