const makePage = () => ({ goto: jest.fn(), content: jest.fn().mockResolvedValue(""), title: jest.fn().mockReturnValue(""), url: jest.fn().mockReturnValue(""), evaluate: jest.fn(), close: jest.fn(), }); const makeContext = () => ({ newPage: jest.fn().mockResolvedValue(makePage()), cookies: jest.fn().mockResolvedValue([]), addCookies: jest.fn().mockResolvedValue(undefined), addInitScript: jest.fn().mockResolvedValue(undefined), tracing: { start: jest.fn().mockResolvedValue(undefined), // Mimic Playwright writing the trace archive when a path is given stop: jest.fn().mockImplementation(async (opts?: { path?: string }) => { if (opts?.path) { // eslint-disable-next-line @typescript-eslint/no-require-imports await require("node:fs/promises").writeFile(opts.path, "fake trace zip"); } }), }, }); const makeBrowser = () => ({ newContext: jest .fn() .mockImplementation(() => Promise.resolve(makeContext())), close: jest.fn(), }); export const chromium = { launch: jest.fn().mockImplementation(() => Promise.resolve(makeBrowser())), };