Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: use new headless for puppeteer tests #15374

Merged
merged 10 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/test/gather/gatherers/accessibility-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('a11y audits + aXe', () => {

before(async () => {
browser = await puppeteer.launch({
headless: 'new',
executablePath: getChromePath(),
});
});
Expand Down
30 changes: 11 additions & 19 deletions core/test/scenarios/pptr-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,19 @@ function createTestState() {
serverBaseUrl: '',
secondaryServerBaseUrl: '',

/**
* @param {number=} port
* @param {number=} secondaryPort
*/
installServerHooks(port = 10200, secondaryPort = 10503) {
installSetupAndTeardownHooks() {
before(async () => {
this.server = new Server(port);
this.secondaryServer = new Server(secondaryPort);
await this.server.listen(port, '127.0.0.1');
await this.secondaryServer.listen(secondaryPort, '127.0.0.1');
this.server = new Server(10200);
this.secondaryServer = new Server(10503);
await this.server.listen(10200, '127.0.0.1');
await this.secondaryServer.listen(10503, '127.0.0.1');
this.serverBaseUrl = `http://localhost:${this.server.getPort()}`;
this.secondaryServerBaseUrl = `http://localhost:${this.secondaryServer.getPort()}`;
});

after(async () => {
await this.server.close();
await this.secondaryServer.close();
});
},

installSetupAndTeardownHooks() {
this.installServerHooks();

before(async () => {
this.browser = await puppeteer.launch({
headless: true,
headless: 'new',
executablePath: getChromePath(),
ignoreDefaultArgs: ['--enable-automation'],
});
Expand Down Expand Up @@ -98,6 +85,11 @@ function createTestState() {
after(async () => {
await this.browser.close();
});

after(async () => {
await this.server.close();
await this.secondaryServer.close();
});
},

/**
Expand Down
2 changes: 1 addition & 1 deletion flow-report/test/flow-report-pptr-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Lighthouse Flow Report', () => {

before(async () => {
browser = await puppeteer.launch({
headless: true,
headless: 'new',
executablePath: getChromePath(),
});
page = await browser.newPage();
Expand Down
1 change: 1 addition & 0 deletions report/test/renderer/report-renderer-axe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('ReportRendererAxe', () => {

before(async () => {
browser = await puppeteer.launch({
headless: 'new',
executablePath: getChromePath(),
});
});
Expand Down
2 changes: 1 addition & 1 deletion treemap/test/treemap-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Lighthouse Treemap', () => {
beforeEach(async () => {
if (!browser) {
browser = await puppeteer.launch({
headless: true,
headless: 'new',
executablePath: getChromePath(),
});
}
Expand Down
3 changes: 2 additions & 1 deletion viewer/test/viewer-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Lighthouse Viewer', () => {

// start puppeteer
browser = await puppeteer.launch({
headless: true,
headless: 'new',
executablePath: getChromePath(),
});
viewerPage = await browser.newPage();
Expand All @@ -86,6 +86,7 @@ describe('Lighthouse Viewer', () => {
});

async function ensureNoErrors() {
await viewerPage.bringToFront();
await viewerPage.evaluate(() => new Promise(window.requestAnimationFrame));
const theErrors = pageErrors;
pageErrors = [];
Expand Down
Loading