@mocksmith/playwright
v0.3.3
Published
Playwright fixture for mocksmith: an isolated mock session per test, with external requests blocked.
Downloads
86
Maintainers
Readme
@mocksmith/playwright
A Playwright fixture for mocksmith: every test gets its own isolated mock session, and external requests are blocked so tests never depend on the network.
npm install --save-dev @mocksmith/playwrightimport { expect } from '@playwright/test';
import { mockTest } from '@mocksmith/playwright';
mockTest('serves session data', async ({ page, initMockContext }) => {
await initMockContext(session);
expect(await (await page.request.get('/api/profile')).json()).toMatchObject({ plan: 'pro' });
});Point it at the running server with MOCKSMITH_URI=http://127.0.0.1:3101.
To apply scenarios in tests, add
@mocksmith/scenarios and
import applyScenario from @mocksmith/scenarios/playwright.
License
MIT
