Fork me on GitHub
#kaocha
<
2022-09-28
>
pesterhazy14:09:13

Hi, I've been using kaocha for TDD'ing and I'm really enjoying its speed Sometimes I want to inspect output from one of my tests, for exploring/debugging etc I've found two was to do that: • --no-capture-output: works but gives me the output intermingled with the dots • (prn result) (assert false): failed tests show output, but it pains me to fail a test just to see the output 🙂 So I'm wondering how people inspect output during development?

plexus16:09:32

Seems like a good candidate for tap>.

pesterhazy18:09:51

Can you explain a bit more? I tap> the value, and then it ends up in a separate stdout-like file open in another terminal - or in a graphical window running alongside the terminal?

plexus18:09:41

You can register any handler you like for the tap>, I'm quite fond of using it to send it to Portal. You can then inspect it in the portal gui but also use that to access the value in the repl again. But you could also register a tap handler that bypasses the output capturing. You'd have to grab a reference to system/out or *out* before it gets rebound.

pesterhazy19:09:23

Interesting, I hadn't tried Portal before. Will check it out

robert-stuttaford06:10:15

is there a special trick to getting kaocha + portal working?

plexus07:10:58

In this case I'm not suggesting anything kaocha specific, you can tap values from a test as you can from anywhere. It's just a way to have a side channel for inspecting stuff.

robert-stuttaford10:10:40

ok, when i tried nothing arrived in Portal, although i didn't try incredibly hard 😅 will try it again

plexus13:10:45

This assumes you're running both in the same jvm, maybe you're running kaocha from the cli?

robert-stuttaford14:10:01

let me test a bit more before wasting any of your valuable time 😅

djblue21:10:36

If you are running tests in another process, you can use the https://cljdoc.org/d/djblue/portal/0.31.0/doc/remote-api to chuck stuff over the wall 💯 The tricky bit is coordinating the portal server port which can be done via hard coding it with portal.api/start 👍

plexus09:10:11

If portal had been built on top of Funnel this would work automagically 😉 💅

djblue19:10:04

True, although Portal has migrated away from transit-clj since cljs vendors an older aot version that was missing features I needed in a later version. Also ran into some issues with metadata.

pesterhazy19:10:52

FWIW I just added Portal to my kaocha watch process and it worked as expected. I added a tap and then tap>'ed values from within tests

awesome 1
pesterhazy19:10:01

By the way, on macOS, the portal window doesn't seem to have a "presence" for lack of a better word. There's no dock icon and I can't cmd-tab to it

pesterhazy19:10:16

Is that expected? Any way to fix it?

pesterhazy19:10:50

(I can find the window by using exposé or whatever that's called)

2
djblue19:10:54

If you install the pwa https://github.com/djblue/portal/blob/master/doc/guides/standalone.md it can host your local instance :thumbsup:

pesterhazy19:10:33

Nice - can I tap data into the standalone version?

djblue19:10:54

No, you still need to run portal in process but the standalone app can automatically iframe in the UI when you portal.api/open

pesterhazy19:10:25

Great, thanks!

pesterhazy15:09:40

While I'm here, another papercut is stacktraces. I kinda like the fact that kaocha gives me the straight dope, i.e. the unabridged stacktrace. However, my poor 25-row terminal is consumed by mostly kaocha stackframes

kaocha.type.var$eval9283$fn__9285$fn__9290.invoke (var.clj:30)
    kaocha.type.var$eval9283$fn__9285.invoke (var.clj:27)
... and so on. Is there a way to elide the internal frames?

pesterhazy15:09:55

Correct: just measured it, I have 46 rows in my iTerm

plexus16:09:58

Yeah this is an old sore that needs to be revisited. We do some elision but the approach and result are not satisfactory

👍 1