How can I test that a function was called in clojure? I have a function that calls clj-http's request
. I know I can redefine the request
function using with-redefs
in the test, to make sure it doesn't actually make the http call. But I want to also know
1. That my request
stub was called
2. That it was called with the correct argument
If you're open to using #expectations there is a very simple and elegant way to do that https://clojure-expectations.github.io/interactions.html
Thanks that's what I was looking for
(Expectations has integration with clojure.test
so you can take advantage of all the standard tooling -- I'm working on an overhaul of the documentation to make that clearer)
Hi every one!
I was looking for a tool that performs test-coverage in clojurescript that targets nodejs. I have searched on google but I have found nothing: is there such an instrument or I have to use tools already provided for javascript such as istanbuljs/nyc
?
Thanks!
@giovaferra
If you're using doo
to run tests then they have some integration ready with Istanbul.
https://github.com/bensu/doo#measuring-coverage-with-istanbul
The only problem is that, at least until the last time I tried it, the coverage outputs the results using the js sources as it does not have source mapping set up.
but there are karma plugins (which doo uses under the hood) that enable that
it's just the matter of setting it up
Yes, I use doo, but Karma is for browser testing, while I targets Nodejs. It is possible to use it anyway?
@giovaferra ah, I wasn't aware of that, sorry! I've never dealt with nodejs so I assumed it would use that as well
ok 👍 🙂