clj tests work fine, but when I try to run cljs tests or load current file and dependencies, error happens.
Error message:
; Evaluating file: events_test.cljs
; Execution error (ExceptionInfo) at cljs.repl/ns->input (repl.cljc:204).
; THE NAMESPACE WHICH HAS THE FUNCTION THAT I WANT TO TEST does not exist
; Evaluation of file events_test.cljs failed: class clojure.lang.ExceptionInfo
; Running tests for THE NAMESPACE
; No tests found. 馃槺, ns: 0, vars: 0
I hope anyone can give me a hint about what's wrong. Thanks!
Hello! Unfortunately Calva's test runner does not work with ClojureScript. You'll need to either use some other test runner, or run the tests using cljs.test directly. I do both.
Here you can find a link to where this breaks upstream: https://calva.io/test-runner/
@PEZ Maybe we should enhance the test runner to explain this limitation in the output when a user tries to run tests for cljs?
Yes, and/or run the tests differently in waiting for this to be added to cider-nrepl. But minimum should be to inform better about the limitation-
@PEZ @bpringe Oh, thanks!
Question: Do you guys consider to make it work(Calva's test runner work with ClojureScript) or it's just not possible.
It's definitely possible and something we'd like to have in Calva eventually. It's just a matter of either waiting for a solution upstream, possibly helping provide a solution upstream, or adding some maybe temporary solution in Calva.
Also a matter of having the time and priority, as usual. :smile:
It seems they have decided upon a simple solution upstream, it just hasn't been implemented yet:
we can actually evaluate code via the cljs repl environment and if that's the case probably that's the simplest real solution that we can come up with
@PEZ What do you mean by run the tests using cljs.test directly? do you mean using run-tests function? I don't think it's possible because I couldn't even load the .cljs file. Do you mind explain a little bit more?
Hello! Unfortunately Calva's test runner does not work with ClojureScript. You'll need to either use some other test runner, or run the tests using
cljs.testdirectly. I do both.Here you can find a link to where this breaks upstream: https://calva.io/test-runner/
If you can't load the .cljs file you first need to get that fixed. Can you describe what you do to load it and what happens and doesn't happen?
Once that is sorted tests can run using cljs.test/run-tests et al. https://clojuredocs.org/clojure.test/run-tests
@PEZ
After I jack in and hit Load Current File and Dependencies, I get this in my output file:
; Evaluating file: events_test.cljs
; Execution error (ExceptionInfo) at cljs.repl/ns->input (repl.cljc:204).
; NAMESPACE THAT HAS THE FUNCTION I NEED TO TEST does not exist
; Evaluation of file events_test.cljs failed: class clojure.lang.ExceptionInfo
It'll switch to my test namespace anyway and this's what I get after I run (run-tests) command:
(cljs.test/run-tests)
; WARNING: Use of undeclared Var cljs.test/run-block at line 1
; WARNING: Use of undeclared Var cljs.test/empty-env at line 1
; WARNING: Use of undeclared Var cljs.test/set-env! at line 1
; WARNING: Use of undeclared Var cljs.test/do-report at line 1
; WARNING: Use of undeclared Var cljs.test/block at line 1
; WARNING: Use of undeclared Var cljs.test/get-current-env at line 1
; WARNING: Use of undeclared Var cljs.test/set-env! at line 1
; WARNING: Use of undeclared Var cljs.test/empty-env at line 1
; WARNING: Use of undeclared Var cljs.test/test-vars-block at line 1
; WARNING: Use of undeclared Var cljs.test/clear-env! at line 1
; WARNING: Use of undeclared Var cljs.test/do-report at line 1
; WARNING: Use of undeclared Var cljs.test/get-and-clear-env! at line 1
; WARNING: Use of undeclared Var cljs.test/set-env! at line 1
; WARNING: Use of undeclared Var cljs.test/do-report at line 1
; WARNING: Use of undeclared Var cljs.test/report at line 1
; WARNING: Use of undeclared Var cljs.test/clear-env! at line 1
; #object[TypeError TypeError: Cannot read property 'run_block' of undefined]
; Execution error (ExceptionInfo) at cljs.repl/ns->input (repl.cljc:204).
It seems there is some error in your test file source code. I haven't done a whole lot of cljs work, so @PEZ may be able to provide better info, but I don't see a function like ns->input in the cljs.repl namespace here: http://cljs.github.io/api/cljs.repl/. Maybe it's something that was removed? In any case, it does seem to exist for you, but an error is thrown from within it. :thinking:
You may want to try slimming down your test file by removing parts and seeing if it will successfully load (via the load current file command). Another thing you can do is post your test ns code here, but it may still be hard to help without having the rest of the project.