I am in love with Livebook! My hope is to use it for everything from data exploration and feature planning, documentation, and TDD in a cohesive way… amazing if it comes together!
On the TDD front, I have successfully connected a livebook notebook to my local app and am able to run basic tests. However, I’m stumped trying to test data creation. The snippet below worked the first time this was run (without the ref to the DataCase), but then fails thereafter because the original record is not being deleted after the test as happens with mix test. I tried adding the use DataCase line, but that results in the compile error below. Is this possible and can someone point me to any documentation to assist?
Many thanks in advance!
ExUnit.start(autorun: false)
defmodule MyTest do
use ExUnit.Case, async: true
# Everything above is boiler plate for livebook testing
use myApp.DataCase
alias myApp.Members
alias myApp.Members.Member
test "creates new Member with valid attrs and sets member_uuid" do
assert {:ok, %Member{member_uuid: member_uuid}} =
Members.create_member(%{name: "New Member", member_type: "foe", collapsed_name: "newmember"})
refute nil == member_uuid
end
end
# run below is boiler plate for livebook testing
ExUnit.run()
** (CompileError) priv/livebook/Adventures_in_testing.livemd#cell:6: module PreOrderApp.DataCase is not > loaded and could not be found
(elixir 1.13.2) expanding macro: Kernel.use/1
priv/livebook/Adventures_in_testing.livemd#cell:6: MyTest (module)