Skip to content

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

test: unflake interception test (#2558)

Dmitry Gozman39019e88632c
diff --git a/test/interception.spec.js b/test/interception.spec.js
index 5626547673..65088a8c30 100644
--- a/test/interception.spec.js
+++ b/test/interception.spec.js
@@ -170,12 +170,15 @@ describe('Page.route', function() {
});
it('should be abortable', async({page, server}) => {
await page.route(/\.css$/, route => route.abort());
- let failedRequests = 0;
- page.on('requestfailed', event => ++failedRequests);
+ let failed = false;
+ page.on('requestfailed', request => {
+ if (request.url().includes('.css'))
+ failed = true;
+ });
const response = await page.goto(server.PREFIX + '/one-style.html');
expect(response.ok()).toBe(true);
expect(response.request().failure()).toBe(null);
- expect(failedRequests).toBe(1);
+ expect(failed).toBe(true);
});
it('should be abortable with custom error codes', async({page, server}) => {
await page.route('**/*', route => route.abort('internetdisconnected'));