Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test(route): add another route test (#2800)

Pavel Feldmand484e04a089c
diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.js
index 2fe288de4f..9be5d45380 100644
--- a/test/browsercontext.spec.js
+++ b/test/browsercontext.spec.js
@@ -471,6 +471,20 @@ describe('BrowserContext.route', () => {
expect(await response.text()).toBe('page');
await context.close();
});
+ it('should fall back to context.route', async({browser, server}) => {
+ const context = await browser.newContext();
+ await context.route('**/empty.html', route => {
+ route.fulfill({ status: 200, body: 'context' });
+ });
+ const page = await context.newPage();
+ await page.route('**/non-empty.html', route => {
+ route.fulfill({ status: 200, body: 'page' });
+ });
+ const response = await page.goto(server.EMPTY_PAGE);
+ expect(response.ok()).toBe(true);
+ expect(await response.text()).toBe('context');
+ await context.close();
+ });
});
describe('BrowserContext.setHTTPCredentials', function() {