chore: get rid of 'electron-to-chromium' dependency (#28826)

This commit is contained in:
Max Schmitt 2024-01-03 19:49:37 +01:00 committed by GitHub
parent d8733d9229
commit abc746bd7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 10 deletions

1
package-lock.json generated
View File

@ -45,7 +45,6 @@
"cross-env": "^7.0.3",
"dotenv": "^16.0.0",
"electron": "19.0.11",
"electron-to-chromium": "^1.4.212",
"enquirer": "^2.3.6",
"esbuild": "^0.18.11",
"eslint": "^8.55.0",

View File

@ -83,7 +83,6 @@
"cross-env": "^7.0.3",
"dotenv": "^16.0.0",
"electron": "19.0.11",
"electron-to-chromium": "^1.4.212",
"enquirer": "^2.3.6",
"esbuild": "^0.18.11",
"eslint": "^8.55.0",

View File

@ -0,0 +1,2 @@
console.log(process.versions['chrome'])
process.exit(0);

View File

@ -21,8 +21,6 @@ import type { PageTestFixtures, PageWorkerFixtures } from '../page/pageTestApi';
import type { TraceViewerFixtures } from '../config/traceViewerFixtures';
import { traceViewerFixtures } from '../config/traceViewerFixtures';
export { expect } from '@playwright/test';
import e2c from 'electron-to-chromium';
import { assert } from '../../packages/playwright-core/lib/utils/debug';
type ElectronTestFixtures = PageTestFixtures & {
electronApp: ElectronApplication;
@ -30,13 +28,9 @@ type ElectronTestFixtures = PageTestFixtures & {
newWindow: () => Promise<Page>;
};
const electronVersion = require('electron/package.json').version;
const chromiumVersion = e2c.fullVersions[electronVersion];
assert(chromiumVersion, `Chromium version for Electron version ${electronVersion} is not found.`);
export const electronTest = baseTest.extend<TraceViewerFixtures>(traceViewerFixtures).extend<ElectronTestFixtures, PageWorkerFixtures>({
browserVersion: [chromiumVersion, { scope: 'worker' }],
browserMajorVersion: [Number(chromiumVersion.split('.')[0]), { scope: 'worker' }],
browserVersion: [({}, use) => use(process.env.ELECTRON_CHROMIUM_VERSION), { scope: 'worker' }],
browserMajorVersion: [({}, use) => use(Number(process.env.ELECTRON_CHROMIUM_VERSION.split('.')[0])), { scope: 'worker' }],
isAndroid: [false, { scope: 'worker' }],
isElectron: [true, { scope: 'worker' }],
isWebView2: [false, { scope: 'worker' }],

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import assert from 'assert';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
export default async () => {
const result = await spawnAsync('npx', ['electron', require.resolve('./electron-print-chromium-version.js')], {
shell: true,
});
const chromiumVersion = result.stdout.trim();
assert(result.code === 0);
assert(chromiumVersion.length > 0);
process.env.ELECTRON_CHROMIUM_VERSION = chromiumVersion;
};

View File

@ -38,6 +38,7 @@ const config: Config<CoverageWorkerOptions & PlaywrightWorkerOptions & Playwrigh
['json', { outputFile: path.join(outputDir, 'report.json') }],
] : 'line',
projects: [],
globalSetup: './globalSetup.ts'
};
const metadata = {