Skip to content

Commit

Permalink
refactor!: make replay compatible with Puppeteer v22 (#758)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikolay Vitkov <[email protected]>
  • Loading branch information
OrKoN and Lightning00Blade authored Feb 5, 2024
1 parent 41c3d10 commit e594f50
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 94 deletions.
12 changes: 6 additions & 6 deletions __snapshots__/LighthouseStringifyExtension.test.ts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
exports['LighthouseStringifyExtension handles ending timespan 1'] = `
const fs = require('fs');
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -58,10 +58,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later

exports['LighthouseStringifyExtension handles ending navigation 1'] = `
const fs = require('fs');
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -130,10 +130,10 @@ exports[
'LighthouseStringifyExtension handles multiple sequential navigations 1'
] = `
const fs = require('fs');
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down
4 changes: 2 additions & 2 deletions __snapshots__/lighthouse.test.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ exports[
'Lighthouse user flow run via stringify produces a valid desktop flow report 1'
] = `
const fs = require('fs');
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down
40 changes: 20 additions & 20 deletions __snapshots__/stringify.test.ts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
exports['stringify should print the correct script for a navigate step 1'] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand All @@ -25,10 +25,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
exports[
'stringify should print the correct script for a emulateNetworkCondition step 1'
] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -56,10 +56,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
exports[
'stringify should print the correct script if the target is not the main page 1'
] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -91,10 +91,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
`;

exports['stringify should use step and flow timeouts 1'] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 10000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -129,10 +129,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
exports[
'stringify should print the correct script if the step is within an iframe 1'
] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -165,10 +165,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
`;

exports['stringify should print the correct script for a keydown step 1'] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand All @@ -189,10 +189,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
`;

exports['stringify should print the correct script for a keyup step 1'] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand All @@ -213,10 +213,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
`;

exports['stringify should print the correct script for scroll events 1'] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -247,10 +247,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
exports[
'stringify should print the correct script for waitForElement steps 1'
] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down Expand Up @@ -405,10 +405,10 @@ const puppeteer = require('puppeteer'); // v20.7.4 or later
exports[
'stringify should print the correct script for waitForExpression steps 1'
] = `
const puppeteer = require('puppeteer'); // v20.7.4 or later
const puppeteer = require('puppeteer'); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({headless: 'new'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
const timeout = 5000;
page.setDefaultTimeout(timeout);
Expand Down
4 changes: 1 addition & 3 deletions examples/cjs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const {
const puppeteer = require('puppeteer');

async function main() {
const browser = await puppeteer.launch({
headless: 'new',
});
const browser = await puppeteer.launch();

const page = await browser.newPage();

Expand Down
2 changes: 1 addition & 1 deletion examples/cli-extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PuppeteerRunnerExtension } from '../../lib/main.js';
export default class Extension extends PuppeteerRunnerExtension {
async beforeAllSteps(flow) {
if (!this.browser) {
this.browser = await puppeteer.launch({ headless: 'new' });
this.browser = await puppeteer.launch();
}
if (!this.page) {
this.page = await this.browser.newPage();
Expand Down
4 changes: 1 addition & 3 deletions examples/extend-runner/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { createRunner, PuppeteerRunnerExtension } from '../../lib/main.js';
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
headless: 'new',
});
const browser = await puppeteer.launch();

const page = await browser.newPage();

Expand Down
Loading

0 comments on commit e594f50

Please sign in to comment.