property
test.Test.extend
extend: ExtendTest<object>
Returns a test whose callbacks receive the TestContext with fixtures added to it.
A fixture is set up for the tests that destructure it, and for the returned test's beforeEach() / afterEach() hooks that destructure it. It's torn down after the test.
const test = base.extend<{ server: Server }>({
server: async ({}, use) => {
const server = Bun.serve({ port: 0, fetch: () => new Response("ok") });
await use(server);
await server.stop();
},
});
test("responds", async ({ server }) => {
expect(await (await fetch(server.url)).text()).toBe("ok");
});