Skip to content

Commit

Permalink
fix(e2e): update to use page.waitForTimeout()
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Sep 17, 2020
1 parent 1a907f7 commit e48d306
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/testing/puppeteer/puppeteer-page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { E2EProcessEnv, EmulateConfig, HostElement, JestEnvironmentGlobal } from '@stencil/core/internal';
import type { E2EPage, E2EPageInternal, FindSelector, NewE2EPageOptions, PageDiagnostic } from './puppeteer-declarations';
import type {
E2EPage,
E2EPageInternal,
FindSelector,
NewE2EPageOptions,
PageDiagnostic,
} from './puppeteer-declarations';
import { find, findAll } from './puppeteer-element';
import { initPageEvents, waitForEvent } from './puppeteer-events';
import { initPageScreenshot } from './puppeteer-screenshot';
Expand Down Expand Up @@ -313,7 +319,10 @@ async function waitForChanges(page: E2EPageInternal) {
for (let i = 0; i < len; i++) {
const childElm = children[i];
if (childElm != null) {
if (childElm.tagName.includes('-') && typeof (childElm as HostElement).componentOnReady === 'function') {
if (
childElm.tagName.includes('-') &&
typeof (childElm as HostElement).componentOnReady === 'function'
) {
promises.push((childElm as HostElement).componentOnReady());
}
waitComponentOnReady(childElm, promises);
Expand All @@ -339,7 +348,12 @@ async function waitForChanges(page: E2EPageInternal) {
return;
}

await page.waitFor(100);
if (typeof (page as any).waitForTimeout === 'function') {
// https://github.com/puppeteer/puppeteer/issues/6214
await (page as any).waitForTimeout(100);
} else {
await page.waitFor(100);
}

await Promise.all(page._e2eElements.map(elm => elm.e2eSync()));
} catch (e) {}
Expand Down

0 comments on commit e48d306

Please sign in to comment.