(options: APIOptions = {})
| 343 | * @param options configure browser interaction run |
| 344 | */ |
| 345 | export async function warmup(options: APIOptions = {}): Promise<void> { |
| 346 | const config = options.config ?? defaultConfig; |
| 347 | if (config.verbose) { |
| 348 | info.lowLevel(`Xvfb: ${config.useXVFB}`); |
| 349 | } |
| 350 | const testPlanner = options.testPlanner ?? defaultTestPlanner; |
| 351 | try { |
| 352 | if (config.skipWarmup) { |
| 353 | return; |
| 354 | } |
| 355 | const browser = await APIUtils.getBrowser({warmup: true}); |
| 356 | |
| 357 | const visitPlan = testPlanner.getVisitPlan(); |
| 358 | config.setDevice(visitPlan.device); |
| 359 | |
| 360 | const numOfWarmup = visitPlan.numOfWarmup || 3; |
| 361 | const promises = []; |
| 362 | for (let i = 0; i < numOfWarmup; ++i) { |
| 363 | promises.push(browser.newPage()); |
| 364 | } |
| 365 | const pages = await Promise.all(promises); |
| 366 | info.beginSection('warmup'); |
| 367 | await Promise.all( |
| 368 | pages.map(async page => { |
| 369 | await setupPage(page, {cache: false}); |
| 370 | const interactionManager = new E2EInteractionManager(page, browser); |
| 371 | await interactionManager.warmupInPage(); |
| 372 | }), |
| 373 | ).catch(err => { |
| 374 | info.error(err.message); |
| 375 | }); |
| 376 | info.endSection('warmup'); |
| 377 | |
| 378 | await utils.closePuppeteer(browser, pages, {warmup: true}); |
| 379 | } catch (ex) { |
| 380 | const error = utils.getError(ex); |
| 381 | utils.checkUninstalledLibrary(error); |
| 382 | throw ex; |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | function getConfigFromRunOptions(options: RunOptions): MemLabConfig { |
| 387 | let config = MemLabConfig.getInstance(); |
no test coverage detected
searching dependent graphs…