testing

Testing tools, testing philosophy & methodology...
bringe 2018-06-20T00:25:31.000207Z

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

seancorfield 2018-06-20T00:39:50.000189Z

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

✔️ 1
bringe 2018-06-20T00:52:33.000274Z

Thanks that's what I was looking for

seancorfield 2018-06-20T00:59:13.000172Z

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

👍 1
giovaferra 2018-06-20T09:24:24.000365Z

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.stylianos 2018-06-20T09:43:33.000507Z

@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.stylianos 2018-06-20T09:46:02.000066Z

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.stylianos 2018-06-20T09:47:39.000403Z

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

andre.stylianos 2018-06-20T09:47:59.000135Z

it's just the matter of setting it up

giovaferra 2018-06-20T10:36:55.000450Z

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

andre.stylianos 2018-06-20T10:52:07.000226Z

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

giovaferra 2018-06-20T11:56:23.000201Z

ok 👍 🙂