Playwright
Playwright Integration
Q: How do I integrate Stoobly with Playwright tests?
import { test, expect } from '@playwright/test';
import Stoobly from 'stoobly';
const stoobly = new Stoobly();
const interceptor = stoobly.playwrightInterceptor({
scenarioKey: '<SCENARIO-KEY>',
urls: [new RegExp('https://api.example.com/.*')],
});
test.describe('My Tests', () => {
test.beforeEach(async ({ page }, testInfo) => {
// Required: Set page and test title
await interceptor.withPage(page).apply();
interceptor.withTestTitle(testInfo.title);
});
test('can fetch data', async ({ page }) => {
await page.goto('https://example.com');
// Your test code here
});
});Q: Why do I need to call withPage() and withTestTitle() in Playwright?
withPage() and withTestTitle() in Playwright?Q: When should I use withContext() instead of withPage()?
withContext() instead of withPage()?Q: How do I record requests in Playwright tests?
Last updated