lazytest

hadils 2025-04-20T19:34:51.914269Z

Hi! Trying out lazytest. I am excited by the design principles. I am having a hard time with let expressions inside expect and/or it . Can someone explain what the rules are for local values to be used within a test?

✅ 1
2025-04-20T19:47:04.638709Z

hey there!

2025-04-20T19:48:02.662879Z

let bindings should work as expected within expect and it forms

hadils 2025-04-20T19:49:39.472319Z

I am stuggling with the around not executing

hadils 2025-04-20T19:50:29.762479Z

Here is my code:

(defdescribe module-test
  (let [ipc (volatile! nil)]
    (describe "shopping list"
              {:context [(around [f]
                                 (println "before")
                                 (vreset! ipc (rtest/create-ipc))
                                 (launch! @ipc)
                                 (f)
                                 (println "after")
                                 (.close @ipc))]}
              (expect
               (let [shopping-list-depot (depot @ipc "*shopping-list-depot")
                     shopping-lists (pstate @ipc "$$shopping-lists")
                     {list-id "shopping-list"} (r/foreign-append!
                                                shopping-list-depot
                                                (sut/map->ShoppingList
                                                 {:list-id (random-uuid)
                                                  :name "Hadil's List"
                                                  :author "Hadil"}))]
                 (it "should create a shopping list"
                  (= {:list-id list-id
                      :name "Hadil's List"
                      :author "Hadil"
                      :subscribers #{}}
                     (r/foreign-select-one [(rp/keypath list-id)] shopping-lists))))))))
It fails because around is not running.

2025-04-20T19:50:30.709769Z

it forms return a thunk, an anonymous function that is called by the runner, so binding calls won't work from outside it calls

2025-04-20T19:52:11.062859Z

oh i see. you have them inside out. it is the test case, expect is the assertion

hadils 2025-04-20T19:52:31.129809Z

Oh! My bad.

2025-04-20T19:53:08.567819Z

heh no worries, "i expect it should work" is just normal english

hadils 2025-04-20T19:53:52.769939Z

That fixed it! Thank you Noah.

2025-04-20T19:54:05.982509Z

glad to help