kaocha

pesterhazy 2022-09-28T14:54:13.821549Z

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?

robert-stuttaford 2022-10-10T06:31:15.348679Z

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

plexus 2022-10-11T09:19:11.407119Z

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

djblue 2022-10-11T19:37:04.839489Z

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.

pesterhazy 2022-10-11T19:38:52.280419Z

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

1
pesterhazy 2022-10-11T19:39:09.714129Z

Nice tool btw @djblue

1
pesterhazy 2022-10-11T19:40:01.995629Z

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

pesterhazy 2022-10-11T19:40:16.777009Z

Is that expected? Any way to fix it?

pesterhazy 2022-10-11T19:40:50.237169Z

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

✅ 1
djblue 2022-10-11T19:41:54.709009Z

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

pesterhazy 2022-10-11T19:44:33.257699Z

Nice - can I tap data into the standalone version?

djblue 2022-10-11T19:46:54.714759Z

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

pesterhazy 2022-10-11T19:48:25.269349Z

Great, thanks!

plexus 2022-10-10T07:40:58.182869Z

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-stuttaford 2022-10-10T10:04:40.809469Z

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

plexus 2022-10-10T13:36:45.527069Z

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

robert-stuttaford 2022-10-10T14:09:01.876609Z

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

djblue 2022-10-10T21:56:36.828409Z

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 👍

robert-stuttaford 2022-10-11T04:57:39.418929Z

thanks!

plexus 2022-09-28T16:32:32.634579Z

Seems like a good candidate for tap>.

pesterhazy 2022-09-28T18:28:51.464669Z

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?

plexus 2022-09-28T18:45:41.021709Z

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.

pesterhazy 2022-09-28T19:06:23.728949Z

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

pesterhazy 2022-09-28T15:25:40.455859Z

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?

pesterhazy 2022-09-28T15:26:55.068209Z

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

plexus 2022-09-28T16:31:58.259479Z

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

👍 1