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

[browser tests] update Puppeteer #12222

Merged
merged 1 commit into from
Feb 27, 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
9 changes: 4 additions & 5 deletions dev-packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,23 @@
"@types/chai": "^4.2.7",
"@types/mocha": "^10.0.0",
"@types/node-fetch": "^2.5.7",
"@types/puppeteer": "^2.0.0",
"chai": "^4.2.0",
"chalk": "4.0.0",
"decompress": "^4.2.1",
"glob": "^8.0.3",
"limiter": "^2.1.0",
"log-update": "^4.0.0",
"mocha": "^10.1.0",
"puppeteer": "^2.0.0",
"puppeteer-to-istanbul": "^1.2.2",
"puppeteer": "^19.7.2",
"puppeteer-core": "^19.7.2",
"puppeteer-to-istanbul": "^1.4.0",
"temp": "^0.9.1",
"yargs": "^15.3.1"
},
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^10.0.0",
"@types/node-fetch": "^2.5.7",
"@types/proxy-from-env": "^1.0.1",
"@types/puppeteer": "^2.0.0"
"@types/proxy-from-env": "^1.0.1"
}
}
12 changes: 9 additions & 3 deletions dev-packages/cli/src/run-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import * as net from 'net';
import * as puppeteer from 'puppeteer';
import * as puppeteer from 'puppeteer-core';
import newTestPage, { TestFileOptions } from './test-page';

export interface TestOptions {
start: () => Promise<net.AddressInfo>
launch?: puppeteer.LaunchOptions
launch?: puppeteer.PuppeteerLaunchOptions
files?: Partial<TestFileOptions>
coverage?: boolean
}
Expand Down Expand Up @@ -50,8 +50,14 @@ export default async function runTest(options: TestOptions): Promise<void> {
// the app has focus, to avoid failures of tests that query the UI's state.
if (launch && launch.devtools) {
promises.push(testPage.waitForSelector('#theia-app-shell.p-Widget.theia-ApplicationShell')
.then(e => e.click()));
.then(e => {
// eslint-disable-next-line no-null/no-null
if (e !== null) {
e.click();
}
}));
}

// Clear application's local storage to avoid reusing previous state
promises.push(testPage.evaluate(() => localStorage.clear()));
await Promise.all(promises);
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/src/test-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* eslint-disable @typescript-eslint/no-explicit-any */

import * as puppeteer from 'puppeteer';
import * as puppeteer from 'puppeteer-core';
const collectFiles: (options: TestFileOptions) => string[] = require('mocha/lib/cli/collect-files');

export interface TestFileOptions {
Expand Down
5 changes: 4 additions & 1 deletion dev-packages/cli/src/theia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import downloadPlugins from './download-plugins';
import runTest from './run-test';
import { LocalizationManager, extract } from '@theia/localization-manager';

const { executablePath } = require('puppeteer');

process.on('unhandledRejection', (reason, promise) => {
throw reason;
});
Expand Down Expand Up @@ -527,7 +529,8 @@ async function theiaCli(): Promise<void> {
args: ['--no-sandbox'],
// eslint-disable-next-line no-null/no-null
defaultViewport: null, // view port can take available space instead of 800x600 default
devtools: testInspect
devtools: testInspect,
executablePath: executablePath()
},
files: {
extension: testExtension,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@types/chai-string": "^1.4.0",
"@types/jsdom": "^11.0.4",
"@types/node": "16",
"@types/puppeteer": "^2.0.0",
"@types/sinon": "^10.0.6",
"@types/temp": "^0.8.29",
"@types/uuid": "^7.0.3",
Expand Down Expand Up @@ -45,8 +44,9 @@
"node-gyp": "^9.0.0",
"nsfw": "^2.2.4",
"nyc": "^15.0.0",
"puppeteer": "^2.0.0",
"puppeteer-to-istanbul": "^1.2.2",
"puppeteer": "^19.7.2",
"puppeteer-core": "^19.7.2",
"puppeteer-to-istanbul": "^1.4.0",
"rimraf": "^2.6.1",
"sinon": "^12.0.0",
"temp": "^0.8.3",
Expand Down
Loading