A network mocking library for your SSR applications. Fixture http network requests on your server-side application for browser automation testing without having to modify your application logic.
Check out the documentation to get started.
Don't see your framework? Create a custom server integration or a custom client integration. Alternatively submit a pull request or report an issue to add support for your framework.
import { expect } from "@playwright/test";
import { test } from "@mocky-balboa/playwright";
test("a route that performs server and client network requests", async ({ page, mocky }) => {
// Mocks the request on both the client and the server
mocky.route("**/api/endpoint", (route) => {
return route.fulfill({
status: 200,
body: JSON.stringify({ message: "Hello, World!" }),
headers: { "Content-Type": "application/json" },
});
}, {
// Optionally configure the route
// type: "both" to mock on both client and server (default behaviour)
// type: "server-only" to mock on the server only
// type: "client-only" to mock on the client only
});
await page.goto("http://localhost:3000");
});See examples for example projects.
See contributing for more information.