I am unable to run tests. It complains on missing ring’s mock request. I initially thought that the REPL might not have been launched with the right alias, so I launched it with the right alias, but it is still bombing for that reason
How do I get nrepl to pick up deps.edn’s src/test etc?
I mean the aliases in deps.edn
I’m doing Spc U
followed by , '
and then typing in the alias I awnt
*want
However, it doesn’t seem to be picking the dependency
my deps.edn has a test alias that contains the mock lib I am using
The alias used with Cider should include the test
path, or as a hack you can add test
to the main path definition in deps.edn
Create a dir-locals.el
file to set the default aliases for a project and starting Cider will then use them. Here is how to create a dir locals (although you need a different variable) https://practicalli.github.io/spacemacs/clojure-projects/monorepo-nested-projects.html
Here is a post that explains all the options, towards the end is the dir-locals example https://practicalli.github.io/blog/posts/cider-jack-in-to-clojure-cli-projects-from-spacemacs/
((clojure-mode . ((cider-clojure-cli-global-options . "-A:alias-names"))))
You will need to reopen the Clojure file (or revert buffer) to force the dir-locals.el file to be read by Emacs
If that doesn’t fix it, I can take a look at the code (if you are able to share it)
Also ensure that the deftest functions have been evaluated and you have included the relevant requires and dependencies.
I got the tesst working. Thanks. I was putting the -A after the -S so the deps weren’t taking. My fault
However, upon rerunning tests, I am not sure where the reports are. The cider-test-report buffer shows an older result
If tests are changed without re-evaluating those tests, the results of the previous version will be shown. Is that what is happening? Same if you change the name of a deftest
function, the old one will run as its still in the memory of the REPL.
I am changing a test, saving it and typing in , t a
, t a
in the test code buffer will evaluate all the functions in that namespace, so any changes should get picked up. Running the tests from a source code buffer does not evaluate the test code and therefore any changes in test code is not picked up, unless you go and evaluate them, eg, , e f
on the deftest code.
isn't , t a
for running all the tests?
It was changed some time ago I think; it's now , t n
to run ns tests.
I've not used ns tests, whats that? Is it just for the specific namespace you are in and does it evaluate the current test code in the buffer?
You said
> , t a
in the test code buffer will evaluate all the functions in that namespace
I thought you meant this to run all the tests in a particular namespace (buffer).
, t a
used to work like that but now it's , t n
Ah yes, I was really talking about picking up code changes rather than the scope of tests that are run. Sorry for the confusion.
The test report only shows if you have failed tests by default. If all tests pass, a message is shown in the mini-buffer and a test report is not generated, so , t b
does not find a report.
Once a test report is generated, it should be updated each time , t a
is run.
To have the test report generated on success, set the custom variable cider-test-show-report-on-success
to true in the Clojure layer configuration. For example:
(clojure :variables
clojure-toplevel-inside-comment-form t
cider-overlays-use-font-lock t
clojure-enable-linters 'clj-kondo
cider-test-show-report-on-success t)