Checks one block of code for N+1 queries inside an ExUnit test.
import EctoDoctor.RepeatedQueries.Assertions
test "lists posts", %{conn: conn} do
assert_no_repeated_queries(fn -> get(conn, ~p"/posts") end)
endThe block is scanned on its own so its queries don't count toward the test's own scan.
Summary
Functions
Fails the test when the function runs an N+1 query and shows where it came from.
Fails the test when the function runs no N+1 query, such as to prove the old code is still caught.