I have some cljs.test tests. I'm connected to the REPL ran by figwheel, and have run (use 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl) to get a cljs repl. Compiling and evaling CLJS works fine, but CIDER's test functionality appears to be confused. cider-test-run-tests (C-c ,) claims it can't find the relevant namespace:
Testing...
No tests namespace: crunch.ctk-test
... when run from either crunch.ctk or crunch.ctk-test, even though I can run/eval stuff in there just fine.
I have a clojurescript / clojurec project that uses cljs.test too, but it works for me. I set up my tests with reader conditionals to make them portable both to clojure and clojurescript. Perhaps you could work around the issue that way, if your tests are portable.
What does your project.clj look like? It's possible it cannot find the tests due to misconfiguration.
Unfortunately, my tests are not meaningfully portable. They rely heavy on the DOM. The code I'm writing is a GreaseMonkey userscript, so differences between implementations (different browsers or maybe a JVM implementation somewhere) are important.
Here's my project.clj:
(defproject crunch "0.1.0-SNAPSHOT"
:description "A workout for your CORE"
:url "https://github.com/lvh/crunch"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.107" :scope "provided"]
;; Fancy pattern matching & logic programming
[org.clojure/core.match "0.3.0-alpha4"]
[org.clojure/core.logic "0.8.10"]
;; React
[cljsjs/react "0.13.3-1"]
[reagent "0.5.0"]
[reagent-forms "0.5.6"]
[reagent-utils "0.1.5"]
;; Bootstrap tricks
[wilson "0.9.0"]
;; DOM tricks
[prismatic/dommy "1.1.0"]
[hickory "0.5.4"]
;; Time
[com.andrewmcveigh/cljs-time "0.3.11"]
;; Debugging and logging
[com.taoensso/timbre "4.1.1"]]
:source-paths ["test" "src"]
:target-path "target/%s"
:clean-targets ^{:protect false} [:target-path "out" "resources/public/cljs"]
:cljsbuild {:builds {:app {:source-paths ["src" "test"]
:figwheel true
:compiler
{:main "crunch.core"
:asset-path "cljs/out"
:output-to "resources/public/cljs/main.js"
:output-dir "resources/public/cljs/out"}}
:test {:source-paths ["src" "test"]
:main "crunch.runner"
:compiler {:output-to "target/test.js"
:optimizations :whitespace
:pretty-print true}}}}
:profiles
{:dev-common
;; (use 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl)
{:dependencies [;; Client side building
[figwheel "0.3.7"]
[cljsbuild "1.1.0"]
[org.clojure/tools.nrepl "0.2.10"]
;; Client side testing
[doo "0.1.4"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]]
:plugins [[lein-figwheel "0.3.7"]
[lein-cljsbuild "1.1.0"]
[lein-doo "0.1.4"]
[lein-cljfmt "0.2.1"]]
:figwheel {:css-dirs ["resources/public/css"]
:nrepl-port 7002}
:env {:dev true}}
:dev-overrides {};; Set this in profiles.clj
:dev [:dev-common :dev-overrides]})
Unfortunately, my tests are not meaningfully portable.
From what you've described of the problem, it sounds like the content of the tests is probably irrelevant.
The problem is more likely related to how your directories/namespaces/src-paths are structured.
Sorry; I somehow missed that you gave a suggestion of finding the issue:
test/cljs/* and test/clj/*. I've merged these into one, but didn't resolve the issue:βββ test
βββ shrieker
βββ vendor
βΒ Β βββ api_test.cljs
βββ celery_test.clj
βββ core_test.cljs
βββ deployment_test.clj
βββ dom_test.cljs
βββ handler_test.clj
βββ home_test.cljs
βββ insight_test.cljs
βββ provisioning_test.cljs
βββ rms_test.clj
βββ runner.cljs
βββ test_macros.clj
βββ utils_test.cljs
The namespaces are appropriate for that sturcture, e.g. myproj.utils-test.
@sp3ctum Are you using figwheel's REPL? I think this might have something to do with it...
Yeah, I'm using figwheel's repl. I think with that structure your tests
should work if they're in namespaces such as shrieker.foo.
Closing this as it doesn't seem like there's anything for the CIDER team to do here. Feel free to re-open if that isn't the case.
How could I make this actionable? Would a public repo and reproduction steps (that show the problem for me) help?
@lvh yes, that would be great
OK, steps that reproduce for me:
lein doo phantom test once, or you can trust Travis.rlwrap lein figwheel (presumably rlwrap doesn't matter ;))helm-find-files to go to that new directoryC-c M-c (cider-connect) to localhost, port 7002. REPL appears, works fine (this is a Clojure REPL).(use 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl). This will block until you open a browser and go to localhost:3449. Once that is done, Clojurescript REPL appears, and works fine.src/reason/core.cljs, C-c , (cider-test-run-tests). *Messages* shows:Running tests in reason.core-test...
No tests namespace: reason.core-test
test/reason/core_test.cljs. C-c , again. Same messages.core_test.cljs, compile buffer (C-c C-k). Works fine. C-c , still fails, even now there's definitely a namespace reason.core-test. Verify this by, in the core_test.cljs buffer, doing C-c M-n, and evaling e.g. prefix-test.core.cljs, C-c , still fails with the same error, but recompiling (C-c C-k) works fine, evaling things in the REPL after switching to that ns works fine.Given your earlier comments I'm guessing you can reproduce everything, except that C-c , just works? If so, at least that will give me somewhere to start digging.
@lvh I was going by @sp3ctum's comments. I got the impression it was working fine for him and that this was about the structure of the project.
@sp3ctum: Could you check if the above repro works for you?
Hi guys, I just tried with @lvh 's repro instructions, and could reproduce everything just like he said.
; CIDER 0.10.0 (Java 1.7.0_06, Clojure 1.7.0, nREPL 0.2.12)
emacs-version
;; => "24.5.1"
On Windows 7, did not use rlwrap :)
Actually I can reproduce this in another project as well. I never used the feature with cljs so I must have missed the fact it did not work.
running tests in clojurescript is currently not working according to the docu and the source I've read
Is problem still available ?
Yes, this problem is still unresolved.
I can reproduce it in my project here https://github.com/sp3ctum/squanmate like this:
M-x cider-jack-in-clojurescriptcider-test-run-project-testsWhen doing this, I get this output:
helm-M-x: βcider-test-run-project-testsβ doesnβt support ClojureScript
Using
CIDER 0.15.1snapshot (package: 20170729.133)
I am on it, but I am so newbie.
I am not expecting a result in 10 days.
@sp3ctum, Thanks for the reply!
Having the same issue...
Connected to nREPL server - nrepl://localhost:39960
CIDER 0.17.0snapshot (package: 20180124.1228), nREPL 0.2.13
Clojure 1.9.0, Java 1.8.0_152
In my case, I was able to work around the issue by using doo which was a really easy way to setup a continuous test runner (watcher) that compiles cljs->js and then runs unit tests.
If you're struggling with running your tests, maybe that can help right now.
I agree, that's for running all tests...
But it doesn't solve the problem to run tests with cider-nrepl. It's pretty nice to just run a test (and show the result inline) with a shortkey from you editor while programming. I'd love to have that functionality in cljs. Not sure how to do that with doo.
Yeah you're definitely right. Doo only runs all tests at the same time, and
it can get confusing when you have a lot of failures, since the errors pile
up and become unreadable.
On Jan 26, 2018 10:49, "kurtosys" notifications@github.com wrote:
I agree, that's for running all tests...
But it doesn't solve the problem to run tests with cider-nrepl. It's
pretty nice to just run a test (and show the result inline) with a shortkey
from you editor while programming. I'd love to have that functionality in
cljs. Not sure how to do that with doo.β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/clojure-emacs/cider/issues/1268#issuecomment-360719582,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AASW9_h6RI3V8LgTWDbWAoVJaO3KXle-ks5tOZGQgaJpZM4FupKx
.
Yeah, it's not only about having a lot of failures, it's also about: if I need only 1 or 2 tests to run, I don't want to compile and run everything over and over again. It'd be about checking my cljs code (not about a full compiled version of my app). Anyway... I'd just love to see running tests working, so I can integrate it in my workflow similar to what I do in clojure.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!
The test runner functionality is Clojure-only at the moment. Changing this is on the roadmap, but given our limited resources I doubt we'll tackle it soon.