Fork me on GitHub
#spacemacs
<
2020-06-04
>
craftybones08:06:46

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

craftybones08:06:51

How do I get nrepl to pick up deps.edn’s src/test etc?

craftybones08:06:56

I mean the aliases in deps.edn

craftybones08:06:27

I’m doing Spc U followed by , ' and then typing in the alias I awnt

craftybones08:06:36

However, it doesn’t seem to be picking the dependency

craftybones08:06:17

my deps.edn has a test alias that contains the mock lib I am using

practicalli-john08:06:53

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

practicalli-john08:06:22

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

practicalli-john08:06:42

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/

practicalli-john08:06:50

((clojure-mode . ((cider-clojure-cli-global-options . "-A:alias-names"))))

practicalli-john08:06:21

You will need to reopen the Clojure file (or revert buffer) to force the dir-locals.el file to be read by Emacs

practicalli-john08:06:15

If that doesn’t fix it, I can take a look at the code (if you are able to share it)

practicalli-john08:06:24

Also ensure that the deftest functions have been evaluated and you have included the relevant requires and dependencies.

craftybones09:06:16

I got the tesst working. Thanks. I was putting the -A after the -S so the deps weren’t taking. My fault

craftybones09:06:37

However, upon rerunning tests, I am not sure where the reports are. The cider-test-report buffer shows an older result

practicalli-john09:06:04

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.

craftybones09:06:08

I am changing a test, saving it and typing in , t a

practicalli-john09:06:00

, 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.

jumar12:06:19

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.

practicalli-john12:06:53

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?

jumar12:06:01

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

practicalli-john12:06:02

Ah yes, I was really talking about picking up code changes rather than the scope of tests that are run. Sorry for the confusion.

practicalli-john09:06:59

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)