Fork me on GitHub
#testing
<
2018-06-20
>
bringe00:06:31

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

seancorfield00:06:50

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

✔️ 4
bringe00:06:33

Thanks that's what I was looking for

seancorfield00:06:13

(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)

👍 4
giovaferra09:06:24

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!

andre.stylianos09:06:33

@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

andre.stylianos09:06:02

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.

andre.stylianos09:06:39

but there are karma plugins (which doo uses under the hood) that enable that

andre.stylianos09:06:59

it's just the matter of setting it up

giovaferra10:06:55

Yes, I use doo, but Karma is for browser testing, while I targets Nodejs. It is possible to use it anyway?

andre.stylianos10:06:07

@giovaferra ah, I wasn't aware of that, sorry! I've never dealt with nodejs so I assumed it would use that as well

giovaferra11:06:23

ok 👍 🙂