This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-22
Channels
- # adventofcode (35)
- # beginners (137)
- # braveandtrue (1)
- # calva (33)
- # cider (40)
- # cljsrn (4)
- # clojure (10)
- # clojure-spec (26)
- # clojure-uk (29)
- # clojurescript (18)
- # core-async (6)
- # cursive (1)
- # emacs (2)
- # figwheel-main (17)
- # fulcro (28)
- # jobs-discuss (4)
- # leiningen (1)
- # lumo (19)
- # off-topic (2)
- # om-next (1)
- # reitit (2)
- # rum (8)
- # spacemacs (19)
- # tools-deps (9)
- # yada (3)
@borkdude the examples you'll see around typically show unit tests (or data-driven... testing functions in isolation), using deftest, run-tests, etc from cljs.test
. But those testing macros are extremely non-specific and one of the perks of running tests client-side is you could have direct access to real UI components (avoiding either the need for e.g. Selenium to drive your tests, or a headless browser like PhantomJS that can be kinda painful when debugging). I see no reason why the basic cljs.test
test runner couldn't handle higher-level UI/acceptance tests
I think a good approach could use :extra-mains to set up a testing endpoint on its own page, where you could render various components separately onto the page and then test them. At least if you're using something React-based and can set up state / pass props as needed for each test. With a bit of creativity and a custom reporter (or just use devcards) you could show test results under each rendered component. You could also just run-tests with your whole app loaded, but seems harder and probably slower.
Either way you'd have to be careful about async. Reload, reset DOM/event handlers/state, then trigger run tests (tests probably async too)... you might get some ideas from https://figwheel.org/docs/testing.html and how cljs-test-display does its reloadable setup https://github.com/bhauman/cljs-test-display/blob/be674b314530ac9ed3c4a160d3d3f17eec72f304/src/cljs_test_display/core.cljs#L383-L422 Also you might find using devcards (with its devcards-test macro) could be a really nice way to render components and their test results together.
I’m using figwheel main, but removed the test path in deps.edn. But when I change something there, it still watches that path after restarting
:fig {:extra-deps
{com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
com.bhauman/figwheel-main {:mvn/version "0.1.9"}}
:extra-paths ["src" #_"target"]}