boot-cljs-example icon indicating copy to clipboard operation
boot-cljs-example copied to clipboard

Enable REPL-based testing.

Open sinistral opened this issue 9 years ago • 0 comments

screen shot 2016-05-06 at 21 04 20 Test sources are not currently part of the ClojureScript build. Although the test namespaces themselves may be dispatched to the REPL (e.g. C-k in CIDER), the libraries upon which they depend won't have been compiled and won't be available.

The example testing task has been extended to inject testing namespaces for each namespace that is required by the build (EDN) configuration. It assumes that the convention of naming test namespaces by appending -test to the source namespace is honoured. This isn't too restrictive since this is already required for boot-cljs-test to run tests. Injecting the test namespaces spares users from having to duplicate build configuration only to add testing namespaces, and then keep the two synchronised.

In a REPL, tests now run as:

cljs.user> (app.core-test/silly-test)

FAIL in (silly-test) (cljs$test$run_block@http:365:17)
expected: (= (+ 1 1) 3)
  actual: (not (= 2 3))
;; => nil

rather than:

cljs.user> (app.core-test/silly-test)

eval code
eval@[native code]
http://localhost:3000/main.out/weasel/repl.js:30:469
http://localhost:3000/main.out/weasel/repl.js:39:4
G__10698__2@http://localhost:3000/main.out/cljs/core.js:31903:110
G__10698@http://localhost:3000/main.out/cljs/core.js:32170:24
http://localhost:3000/main.out/weasel/repl.js:184:75
fireListeners@http://localhost:3000/main.out/goog/events/eventtarget.js:284:27
dispatchEventInternal_@http://localhost:3000/main.out/goog/events/eventtarget.js:381:39
dispatchEvent@http://localhost:3000/main.out/goog/events/eventtarget.js:196:56
onMessage_@http://localhost:3000/main.out/goog/net/websocket.js:426:21
[native code]

sinistral avatar May 09 '16 15:05 sinistral