Enable REPL-based testing. - #24
Open
sinistral wants to merge 1 commit into
Open
Conversation
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] ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
testingtask has been extended to inject testingnamespaces for each namespace that is required by the build (EDN)
configuration. It assumes that the convention of naming test namespaces
by appending
-testto the source namespace is honoured. This isn'ttoo restrictive since this is already required for
boot-cljs-testtorun 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:
rather than: