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?
hey there!
let bindings should work as expected within expect and it forms
I am stuggling with the around not executing
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.it forms return a thunk, an anonymous function that is called by the runner, so binding calls won't work from outside it calls
oh i see. you have them inside out. it is the test case, expect is the assertion
Oh! My bad.
heh no worries, "i expect it should work" is just normal english
That fixed it! Thank you Noah.
glad to help