chore: add checks for fonts and icons in request failed error handler from e2e base page.ts (#927)

This commit is contained in:
lisli1 2019-07-10 17:05:42 -07:00 коммит произвёл GitHub
Родитель 53c6a2e6bf
Коммит 6ff148e48a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import * as Puppeteer from 'puppeteer'; import * as Puppeteer from 'puppeteer';
import { includes } from 'lodash';
import { forceTestFailure } from './force-test-failure'; import { forceTestFailure } from './force-test-failure';
import { takeScreenshot } from './generate-screenshot'; import { takeScreenshot } from './generate-screenshot';
import { DEFAULT_NEW_PAGE_WAIT_TIMEOUT_MS, DEFAULT_PAGE_ELEMENT_WAIT_TIMEOUT_MS } from './timeouts'; import { DEFAULT_NEW_PAGE_WAIT_TIMEOUT_MS, DEFAULT_PAGE_ELEMENT_WAIT_TIMEOUT_MS } from './timeouts';
@ -19,7 +20,11 @@ export class Page {
forceEventFailure(`'pageerror' (console.error) with stack: ${error.stack}`); forceEventFailure(`'pageerror' (console.error) with stack: ${error.stack}`);
}); });
underlyingPage.on('requestfailed', request => { underlyingPage.on('requestfailed', request => {
forceEventFailure(`'requestfailed' from '${request.url()}' with errorText: ${request.failure().errorText}`); const url = request.url();
// Checking for 'fonts' and 'icons' in url as a workaround for #923
if (!includes(url, 'fonts') && !includes(url, 'icons')) {
forceEventFailure(`'requestfailed' from '${url}' with errorText: ${request.failure().errorText}`);
}
}); });
underlyingPage.on('response', response => { underlyingPage.on('response', response => {
if (response.status() >= 400) { if (response.status() >= 400) {