|
|
@@ -5,7 +5,7 @@ import puppeteer, {
|
|
|
type PuppeteerLaunchOptions,
|
|
|
} from 'puppeteer'
|
|
|
|
|
|
-export const E2E_TIMEOUT = 30 * 1000
|
|
|
+export const E2E_TIMEOUT: number = 30 * 1000
|
|
|
|
|
|
const puppeteerOptions: PuppeteerLaunchOptions = {
|
|
|
args: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : [],
|
|
|
@@ -13,12 +13,13 @@ const puppeteerOptions: PuppeteerLaunchOptions = {
|
|
|
}
|
|
|
|
|
|
const maxTries = 30
|
|
|
-export const timeout = (n: number) => new Promise(r => setTimeout(r, n))
|
|
|
+export const timeout = (n: number): Promise<any> =>
|
|
|
+ new Promise(r => setTimeout(r, n))
|
|
|
|
|
|
export async function expectByPolling(
|
|
|
poll: () => Promise<any>,
|
|
|
expected: string,
|
|
|
-) {
|
|
|
+): Promise<void> {
|
|
|
for (let tries = 0; tries < maxTries; tries++) {
|
|
|
const actual = (await poll()) || ''
|
|
|
if (actual.indexOf(expected) > -1 || tries === maxTries - 1) {
|
|
|
@@ -55,10 +56,7 @@ export function setupPuppeteer(args?: string[]) {
|
|
|
page.on('console', e => {
|
|
|
if (e.type() === 'error') {
|
|
|
const err = e.args()[0]
|
|
|
- console.error(
|
|
|
- `Error from Puppeteer-loaded page:\n`,
|
|
|
- err.remoteObject().description,
|
|
|
- )
|
|
|
+ console.error(`Error from Puppeteer-loaded page:\n`, err.remoteObject())
|
|
|
}
|
|
|
})
|
|
|
})
|