getKizloClientTestInstance
Wrap a test instance with the real client for end-to-end tests.
getKizloClientTestInstance wraps a getKizloTestInstance
with the real browser client, routing its requests through the test instance's handler. Use it for end-to-end
tests. Calls go through serialization and the same scope rules as production (internal procedures never leave the
server), returning the { data, error, success } result your frontend sees.
Parameters
getKizloClientTestInstance(kizlo)kizlo
A KizloTestInstance from getKizloTestInstance. Its
contract is generated and its handler becomes the client's transport, so requests never leave the process.
Returns
A Promise of a KizloClientTestInstance, a createKizloClient
client bound to the test instance. await it, then call procedures through instance.client. Each resolves to a
{ data, error, success } result.
It complements getKizloTestInstance. That one calls procedures directly through the server client, the quickest
check of what a procedure does. This one goes through the full client to handler path, catching what a direct call
can't: serialization and rules like internal procedures never reaching the browser.
Examples
import { beforeAll, expect, test } from "vitest"
import { getKizloClientTestInstance, getKizloTestInstance, type KizloClientTestInstance } from "kizlo/test"
let instance: KizloClientTestInstance
beforeAll(async () => {
instance = await getKizloClientTestInstance(getKizloTestInstance())
})
test("reads a seeded post over the client", async () => {
const result = await instance.client.posts.get({ params: { identifier: "hello-world-test" } })
expect(result.success).toBe(true)
if (result.success) expect(result.data.slug).toBe("hello-world-test")
})