Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: speed up installation tests by not isolating browser unless required (#27370)

Dmitry Gozmandfc75a1e1a71
diff --git a/.github/workflows/tests_primary.yml b/.github/workflows/tests_primary.yml
index c5e98f08ab..9ef8c8f702 100644
--- a/.github/workflows/tests_primary.yml
+++ b/.github/workflows/tests_primary.yml
@@ -234,7 +234,7 @@ jobs:
env:
DEBUG: pw:install
- run: npm run build
- - run: npx playwright install-deps
+ - run: npx playwright install --with-deps
- run: npm install -g yarn@1
- run: npm install -g pnpm@8
- run: npm run itest
diff --git a/.github/workflows/tests_secondary.yml b/.github/workflows/tests_secondary.yml
index eb41c87cd5..6b55894b75 100644
--- a/.github/workflows/tests_secondary.yml
+++ b/.github/workflows/tests_secondary.yml
@@ -136,7 +136,7 @@ jobs:
env:
DEBUG: pw:install
- run: npm run build
- - run: npx playwright install-deps
+ - run: npx playwright install --with-deps
- run: npm install -g yarn@1
- run: npm install -g pnpm@8
- run: npm run itest
diff --git a/tests/installation/android-types.spec.ts b/tests/installation/android-types.spec.ts
deleted file mode 100755
index f45268c487..0000000000
--- a/tests/installation/android-types.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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 { test } from './npmTest';
-
-test('android types', async ({ exec, tsc, writeFiles }) => {
- await exec('npm i --foreground-scripts playwright');
- await writeFiles({
- 'test.ts':
- `import { AndroidDevice, _android, AndroidWebView, Page } from 'playwright';`,
- });
- await tsc('test.ts');
-});
diff --git a/tests/installation/connect-to-selenium.spec.ts b/tests/installation/connect-to-selenium.spec.ts
index 366665bfa8..a2658e7e02 100755
--- a/tests/installation/connect-to-selenium.spec.ts
+++ b/tests/installation/connect-to-selenium.spec.ts
@@ -20,7 +20,7 @@ import { test } from './npmTest';
test('connect to selenium', async ({ exec, tmpWorkspace }, testInfo) => {
test.skip(os.platform() !== 'linux');
- await exec('npm i --foreground-scripts playwright-core');
+ await exec('npm i playwright-core');
await exec(`node download-chromedriver.js ${tmpWorkspace}`);
const seleniumPath = path.join(tmpWorkspace, 'selenium');
await exec(`node download-selenium.js ${seleniumPath}`);
diff --git a/tests/installation/driver-should-work.spec.ts b/tests/installation/driver-should-work.spec.ts
index 99c57e27c7..2d5e45d3b2 100755
--- a/tests/installation/driver-should-work.spec.ts
+++ b/tests/installation/driver-should-work.spec.ts
@@ -16,7 +16,7 @@
import { test, expect } from './npmTest';
test('driver should work', async ({ exec }) => {
- await exec('npm i --foreground-scripts playwright');
+ await exec('npm i playwright');
await exec('npx playwright install');
await exec('node driver-client.js');
});
@@ -24,7 +24,7 @@ test('driver should work', async ({ exec }) => {
test('driver should ignore SIGINT', async ({ exec }) => {
test.skip(process.platform === 'win32', 'Only relevant for POSIX');
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright-python/issues/1843' });
- await exec('npm i --foreground-scripts playwright');
+ await exec('npm i playwright');
await exec('npx playwright install chromium');
const output = await exec('node driver-client-sigint.js');
const lines = output.split('\n').filter(l => l.trim());
diff --git a/tests/installation/electron-types.spec.ts b/tests/installation/electron-types.spec.ts
deleted file mode 100755
index ccb1eae7d9..0000000000
--- a/tests/installation/electron-types.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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 { test } from './npmTest';
-
-test('electron types', async ({ exec, tsc, writeFiles }) => {
- await exec('npm i --foreground-scripts playwright electron@12');
- await writeFiles({
- 'test.ts':
- `import { Page, _electron, ElectronApplication, Electron } from 'playwright';`
- });
- await tsc('test.ts');
-});
diff --git a/tests/installation/globalSetup.ts b/tests/installation/globalSetup.ts
index 8f9bf4b199..5a42beb334 100644
--- a/tests/installation/globalSetup.ts
+++ b/tests/installation/globalSetup.ts
@@ -14,22 +14,13 @@
* limitations under the License.
*/
-import http from 'http';
-import https from 'https';
-import url from 'url';
-import type net from 'net';
-import debugLogger from 'debug';
import path from 'path';
import fs from 'fs';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
import { rimraf } from 'playwright-core/lib/utilsBundle';
import { TMP_WORKSPACES } from './npmTest';
-import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
-import { calculateSha1 } from '../../packages/playwright-core/lib/utils/crypto';
const PACKAGE_BUILDER_SCRIPT = path.join(__dirname, '..', '..', 'utils', 'pack_package.js');
-const BROWSERS_CACHE_DIR = path.join(TMP_WORKSPACES, 'npm-test-browsers-cache');
-const debug = debugLogger('itest');
async function globalSetup() {
await rimraf(TMP_WORKSPACES);
@@ -83,61 +74,6 @@ async function globalSetup() {
await fs.promises.writeFile(path.join(__dirname, '.registry.json'), JSON.stringify(Object.fromEntries(builds)));
}
-
- const cdnProxyServer = createHttpServer(async (request: http.IncomingMessage, response: http.ServerResponse) => {
- const requestedPath = url.parse(request.url!).path;
- const cachedPath = path.join(BROWSERS_CACHE_DIR, calculateSha1(requestedPath));
- const cachedPathMetaInfo = cachedPath + '.metainfo';
-
- if (!fs.existsSync(cachedPath)) {
- const realUrl = 'https://playwright.azureedge.net' + requestedPath;
- debug(`[cdn proxy] downloading ${realUrl} headers=${JSON.stringify(request.headers)}`);
- const headers = { ...request.headers };
- delete headers['host'];
- const options = {
- ...url.parse(realUrl),
- method: request.method,
- headers,
- };
- const factory = options.protocol === 'https:' ? https : http;
- let doneCallback = () => {};
- const donePromise = new Promise<void>(f => doneCallback = () => {
- debug(`[cdn proxy] downloading ${realUrl} finished`);
- f();
- });
- const realRequest = factory.request(options, (realResponse: http.IncomingMessage) => {
- const metaInfo = {
- statusCode: realResponse.statusCode,
- statusMessage: realResponse.statusMessage || '',
- headers: realResponse.headers || {},
- };
- debug(`[cdn proxy] downloading ${realUrl} statusCode=${realResponse.statusCode}`);
- fs.mkdirSync(path.dirname(cachedPathMetaInfo), { recursive: true });
- fs.writeFileSync(cachedPathMetaInfo, JSON.stringify(metaInfo));
- realResponse.pipe(fs.createWriteStream(cachedPath, { highWaterMark: 1024 * 1024 })).on('close', doneCallback).on('finish', doneCallback).on('error', doneCallback);
- });
- request.pipe(realRequest);
- await donePromise;
- }
-
- const metaInfo = JSON.parse(fs.readFileSync(cachedPathMetaInfo, 'utf-8'));
- response.writeHead(metaInfo.statusCode, metaInfo.statusMessage, metaInfo.headers);
- const done = () => {
- debug(`[cdn proxy] serving ${request.url!} finished`);
- response.end();
- };
- fs.createReadStream(cachedPath, { highWaterMark: 1024 * 1024 }).pipe(response).on('close', done).on('error', done);
- debug(`[cdn proxy] serving ${request.url!} from cached ${cachedPath}`);
- });
-
- cdnProxyServer.listen(0);
- await new Promise(f => cdnProxyServer.once('listening', f));
- process.env.CDN_PROXY_HOST = `http://127.0.0.1:${(cdnProxyServer.address() as net.AddressInfo).port}`;
- console.log('Stared CDN proxy at ' + process.env.CDN_PROXY_HOST);
-
- return async () => {
- await new Promise(f => cdnProxyServer.close(f));
- };
}
export default globalSetup;
diff --git a/tests/installation/npmTest.ts b/tests/installation/npmTest.ts
index 0f2f9e7120..1074a61022 100644
--- a/tests/installation/npmTest.ts
+++ b/tests/installation/npmTest.ts
@@ -61,15 +61,15 @@ type ExecOptions = SpawnOptions & { message?: string, expectToExitWithError?: bo
type ArgsOrOptions = [] | [...string[]] | [...string[], ExecOptions] | [ExecOptions];
type NPMTestOptions = {
- useRealCDN: boolean;
+ isolateBrowsers: boolean;
+ allowGlobalInstall: boolean;
};
type NPMTestFixtures = {
_auto: void;
_browsersPath: string;
tmpWorkspace: string;
- installedSoftwareOnDisk: (registryPath?: string) => Promise<string[]>;
- writeConfig: (allowGlobal: boolean) => Promise<void>;
+ installedSoftwareOnDisk: () => Promise<string[]>;
writeFiles: (nameToContents: Record<string, string>) => Promise<void>;
exec: (cmd: string, ...argsAndOrOptions: ArgsOrOptions) => Promise<string>;
tsc: (args: string) => Promise<string>;
@@ -79,9 +79,10 @@ type NPMTestFixtures = {
export const test = _test
.extend<CommonFixtures, CommonWorkerFixtures>(commonFixtures)
.extend<NPMTestFixtures & NPMTestOptions>({
- useRealCDN: [false, { option: true }],
+ isolateBrowsers: [false, { option: true }],
+ allowGlobalInstall: [false, { option: true }],
_browsersPath: async ({ tmpWorkspace }, use) => use(path.join(tmpWorkspace, 'browsers')),
- _auto: [async ({ tmpWorkspace, exec, _browsersPath, writeConfig }, use) => {
+ _auto: [async ({ tmpWorkspace, exec, _browsersPath, registry, allowGlobalInstall }, use, testInfo) => {
await exec('npm init -y');
const sourceDir = path.join(__dirname, 'fixture-scripts');
const contents = await fs.promises.readdir(sourceDir);
@@ -93,7 +94,20 @@ export const test = _test
packageJSON.pnpm = { overrides: prefixed };
await fs.promises.writeFile(path.join(tmpWorkspace, 'package.json'), JSON.stringify(packageJSON, null, 2));
- await writeConfig(false);
+ const yarnLines = [
+ `registry "${registry.url()}/"`,
+ `cache "${testInfo.outputPath('npm_cache')}"`,
+ ];
+ const npmLines = [
+ `registry = ${registry.url()}/`,
+ `cache = ${testInfo.outputPath('npm_cache')}`,
+ ];
+ if (!allowGlobalInstall) {
+ yarnLines.push(`prefix "${testInfo.outputPath('npm_global')}"`);
+ npmLines.push(`prefix = ${testInfo.outputPath('npm_global')}`);
+ }
+ await fs.promises.writeFile(path.join(tmpWorkspace, '.yarnrc'), yarnLines.join('\n'), 'utf-8');
+ await fs.promises.writeFile(path.join(tmpWorkspace, '.npmrc'), npmLines.join('\n'), 'utf-8');
await use();
if (test.info().status === test.info().expectedStatus) {
@@ -124,28 +138,12 @@ export const test = _test
await use(registry);
await registry.shutdown();
},
- writeConfig: async ({ tmpWorkspace, registry }, use, testInfo) => {
- await use(async (allowGlobal: boolean) => {
- const yarnLines = [
- `registry "${registry.url()}/"`,
- `cache "${testInfo.outputPath('npm_cache')}"`,
- ];
- const npmLines = [
- `registry = ${registry.url()}/`,
- `cache = ${testInfo.outputPath('npm_cache')}`,
- ];
- if (!allowGlobal) {
- yarnLines.push(`prefix "${testInfo.outputPath('npm_global')}"`);
- npmLines.push(`prefix = ${testInfo.outputPath('npm_global')}`);
- }
- await fs.promises.writeFile(path.join(tmpWorkspace, '.yarnrc'), yarnLines.join('\n'), 'utf-8');
- await fs.promises.writeFile(path.join(tmpWorkspace, '.npmrc'), npmLines.join('\n'), 'utf-8');
- });
- },
- installedSoftwareOnDisk: async ({ _browsersPath }, use) => {
- await use(async (registryPath?: string) => fs.promises.readdir(registryPath || _browsersPath).catch(() => []).then(files => files.map(f => f.split('-')[0]).filter(f => !f.startsWith('.'))));
+ installedSoftwareOnDisk: async ({ isolateBrowsers, _browsersPath }, use) => {
+ if (!isolateBrowsers)
+ throw new Error(`Test that checks browser installation must set "isolateBrowsers" to true`);
+ await use(async () => fs.promises.readdir(_browsersPath).catch(() => []).then(files => files.map(f => f.split('-')[0]).filter(f => !f.startsWith('.'))));
},
- exec: async ({ useRealCDN, tmpWorkspace, _browsersPath }, use, testInfo) => {
+ exec: async ({ tmpWorkspace, _browsersPath, isolateBrowsers }, use, testInfo) => {
await use(async (cmd: string, ...argsAndOrOptions: [] | [...string[]] | [...string[], ExecOptions] | [ExecOptions]) => {
let args: string[] = [];
let options: ExecOptions = {};
@@ -164,8 +162,7 @@ export const test = _test
'PATH': process.env.PATH,
'DISPLAY': process.env.DISPLAY,
'XAUTHORITY': process.env.XAUTHORITY,
- 'PLAYWRIGHT_BROWSERS_PATH': _browsersPath,
- ...(useRealCDN ? {} : { PLAYWRIGHT_DOWNLOAD_HOST: process.env.CDN_PROXY_HOST }),
+ ...(isolateBrowsers ? { PLAYWRIGHT_BROWSERS_PATH: _browsersPath } : {}),
...options.env,
}
});
@@ -198,7 +195,7 @@ export const test = _test
});
},
tsc: async ({ exec }, use) => {
- await exec('npm i --foreground-scripts [email protected] @types/node@16');
+ await exec('npm i [email protected] @types/node@16');
await use((args: string) => exec('npx', 'tsc', args, { shell: process.platform === 'win32' }));
},
});
diff --git a/tests/installation/npx-global-help.spec.ts b/tests/installation/npx-global-help.spec.ts
deleted file mode 100755
index fe65dc6bdf..0000000000
--- a/tests/installation/npx-global-help.spec.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('npx playwright --help should not download browsers', async ({ writeConfig, exec, installedSoftwareOnDisk }) => {
- await writeConfig(true);
- const result = await exec('npx playwright --help');
- expect(result).toHaveLoggedSoftwareDownload([]);
- expect(await installedSoftwareOnDisk()).toEqual([]);
- expect(result).not.toContain(`To avoid unexpected behavior, please install your dependencies first`);
-});
diff --git a/tests/installation/npx-global-spec-codegen.spec.ts b/tests/installation/npx-global-spec-codegen.spec.ts
deleted file mode 100755
index 47c4485659..0000000000
--- a/tests/installation/npx-global-spec-codegen.spec.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('npx playwright codegen', async ({ writeConfig, exec, installedSoftwareOnDisk }) => {
- await writeConfig(true);
- const stdio = await exec('npx playwright codegen', { expectToExitWithError: true });
- expect(stdio).toHaveLoggedSoftwareDownload([]);
- expect(await installedSoftwareOnDisk()).toEqual([]);
- expect(stdio).toContain(`Please run the following command to download new browsers`);
-});
diff --git a/tests/installation/npx-global-install.spec.ts b/tests/installation/npx-global.spec.ts
similarity index 57%
rename from tests/installation/npx-global-install.spec.ts
rename to tests/installation/npx-global.spec.ts
index b1d07222e9..4a7a5b47f5 100755
--- a/tests/installation/npx-global-install.spec.ts
+++ b/tests/installation/npx-global.spec.ts
@@ -15,10 +15,25 @@
*/
import { test, expect } from './npmTest';
-test('npx playwright install global', async ({ writeConfig, exec, installedSoftwareOnDisk }) => {
+test.use({ isolateBrowsers: true, allowGlobalInstall: true });
+
+test('npx playwright --help should not download browsers', async ({ exec, installedSoftwareOnDisk }) => {
+ const result = await exec('npx playwright --help');
+ expect(result).toHaveLoggedSoftwareDownload([]);
+ expect(await installedSoftwareOnDisk()).toEqual([]);
+ expect(result).not.toContain(`To avoid unexpected behavior, please install your dependencies first`);
+});
+
+test('npx playwright codegen', async ({ exec, installedSoftwareOnDisk }) => {
+ const stdio = await exec('npx playwright codegen', { expectToExitWithError: true });
+ expect(stdio).toHaveLoggedSoftwareDownload([]);
+ expect(await installedSoftwareOnDisk()).toEqual([]);
+ expect(stdio).toContain(`Please run the following command to download new browsers`);
+});
+
+test('npx playwright install global', async ({ exec, installedSoftwareOnDisk }) => {
test.skip(process.platform === 'win32', 'isLikelyNpxGlobal() does not work in this setup on our bots');
- await writeConfig(true);
const result = await exec('npx playwright install');
expect(result).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
diff --git a/tests/installation/playwright-cdn-should-race-with-timeout.spec.ts b/tests/installation/playwright-cdn-should-race-with-timeout.spec.ts
deleted file mode 100644
index 9768758c9c..0000000000
--- a/tests/installation/playwright-cdn-should-race-with-timeout.spec.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 http from 'http';
-import type { AddressInfo } from 'net';
-import { test, expect } from './npmTest';
-
-test.use({ useRealCDN: true });
-
-test(`playwright cdn should race with a timeout`, async ({ exec }) => {
- const server = http.createServer(() => {});
- await new Promise<void>(resolve => server.listen(0, resolve));
- try {
- await exec('npm i --foreground-scripts playwright');
- const result = await exec('npx playwright install', {
- env: {
- PLAYWRIGHT_DOWNLOAD_HOST: `http://127.0.0.1:${(server.address() as AddressInfo).port}`,
- DEBUG: 'pw:install',
- PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT: '1000',
- },
- expectToExitWithError: true
- });
- expect(result).toContain(`timed out after 1000ms`);
- } finally {
- await new Promise(resolve => server.close(resolve));
- }
-});
diff --git a/tests/installation/playwright-cdn-failover-should-work.spec.ts b/tests/installation/playwright-cdn.spec.ts
similarity index 72%
rename from tests/installation/playwright-cdn-failover-should-work.spec.ts
rename to tests/installation/playwright-cdn.spec.ts
index 96db903217..fabc8012fb 100644
--- a/tests/installation/playwright-cdn-failover-should-work.spec.ts
+++ b/tests/installation/playwright-cdn.spec.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
import { test, expect } from './npmTest';
+import http from 'http';
+import type { AddressInfo } from 'net';
const CDNS = [
'https://playwright.azureedge.net',
@@ -32,11 +34,11 @@ const parsedDownloads = (rawLogs: string) => {
return out;
};
-test.use({ useRealCDN: true });
+test.use({ isolateBrowsers: true });
for (const cdn of CDNS) {
test(`playwright cdn failover should work (${cdn})`, async ({ exec, installedSoftwareOnDisk }) => {
- await exec('npm i --foreground-scripts playwright');
+ await exec('npm i playwright');
const result = await exec('npx playwright install', { env: { PW_TEST_CDN_THAT_SHOULD_WORK: cdn, DEBUG: 'pw:install' } });
expect(result).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
@@ -47,3 +49,22 @@ for (const cdn of CDNS) {
await exec('node esm-playwright.mjs');
});
}
+
+test(`playwright cdn should race with a timeout`, async ({ exec }) => {
+ const server = http.createServer(() => {});
+ await new Promise<void>(resolve => server.listen(0, resolve));
+ try {
+ await exec('npm i playwright');
+ const result = await exec('npx playwright install', {
+ env: {
+ PLAYWRIGHT_DOWNLOAD_HOST: `http://127.0.0.1:${(server.address() as AddressInfo).port}`,
+ DEBUG: 'pw:install',
+ PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT: '1000',
+ },
+ expectToExitWithError: true
+ });
+ expect(result).toContain(`timed out after 1000ms`);
+ } finally {
+ await new Promise(resolve => server.close(resolve));
+ }
+});
diff --git a/tests/installation/playwright-cli-install-should-work-with-languages.spec.ts b/tests/installation/playwright-cli-install-should-work-with-languages.spec.ts
deleted file mode 100755
index 0ef07c8dbe..0000000000
--- a/tests/installation/playwright-cli-install-should-work-with-languages.spec.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('codegen should print the right install command without browsers', async ({ exec }) => {
- await exec('npm i --foreground-scripts playwright');
-
- const pwLangName2InstallCommand = {
- 'java': 'mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"',
- 'python': 'playwright install',
- 'csharp': 'pwsh bin/Debug/netX/playwright.ps1 install',
- '': 'npx playwright install',
- };
-
- for (const [langName, installCommand] of Object.entries(pwLangName2InstallCommand)) {
- await test.step(`codegen should work for ${langName}`, async () => {
- const result = await exec('npx playwright codegen', {
- expectToExitWithError: true,
- env: {
- PW_LANG_NAME: langName,
- }
- });
- expect(result).toContain(installCommand);
- });
- }
-});
diff --git a/tests/installation/playwright-cli-install-should-work.spec.ts b/tests/installation/playwright-cli-install-should-work.spec.ts
index 8001dbaec3..c6d84cedae 100755
--- a/tests/installation/playwright-cli-install-should-work.spec.ts
+++ b/tests/installation/playwright-cli-install-should-work.spec.ts
@@ -14,9 +14,12 @@
* limitations under the License.
*/
import { test, expect } from './npmTest';
+import path from 'path';
+
+test.use({ isolateBrowsers: true });
test('install command should work', async ({ exec, installedSoftwareOnDisk }) => {
- await exec('npm i --foreground-scripts playwright', { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
+ await exec('npm i playwright');
await test.step('playwright install chromium', async () => {
const result = await exec('npx playwright install chromium');
@@ -30,14 +33,59 @@ test('install command should work', async ({ exec, installedSoftwareOnDisk }) =>
expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
});
- await exec('node sanity.js playwright', { env: { PLAYWRIGHT_BROWSERS_PATH: undefined } });
+ await exec('node sanity.js playwright', { env: { PLAYWRIGHT_BROWSERS_PATH: '0' } });
await exec('node sanity.js playwright chromium firefox webkit');
+
+ const packages = ['playwright-chromium', 'playwright-firefox', 'playwright-webkit', '@playwright/browser-chromium', '@playwright/browser-firefox', '@playwright/browser-webkit'];
+ for (const pkg of packages) {
+ await test.step(pkg, async () => {
+ const result = await exec(`npm i ${pkg}`);
+ expect(result).toHaveLoggedSoftwareDownload([]);
+ if (!pkg.includes('@playwright/browser-'))
+ await exec('node sanity.js', pkg, 'chromium firefox webkit');
+ });
+ }
});
test('should be able to remove browsers', async ({ exec, installedSoftwareOnDisk }) => {
- await exec('npm i --foreground-scripts playwright');
+ await exec('npm i playwright');
await exec('npx playwright install chromium');
expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg']);
await exec('npx playwright uninstall');
expect(await installedSoftwareOnDisk()).toEqual([]);
});
+
+test('should print the right install command without browsers', async ({ exec }) => {
+ await exec('npm i playwright');
+
+ const pwLangName2InstallCommand = {
+ 'java': 'mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"',
+ 'python': 'playwright install',
+ 'csharp': 'pwsh bin/Debug/netX/playwright.ps1 install',
+ '': 'npx playwright install',
+ };
+
+ for (const [langName, installCommand] of Object.entries(pwLangName2InstallCommand)) {
+ await test.step(`codegen should work for ${langName}`, async () => {
+ const result = await exec('npx playwright codegen', {
+ expectToExitWithError: true,
+ env: {
+ PW_LANG_NAME: langName,
+ }
+ });
+ expect(result).toContain(installCommand);
+ });
+ }
+});
+
+test('subsequent installs works', async ({ exec }) => {
+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/1651' });
+
+ await exec('npm i @playwright/browser-chromium');
+ // Note: the `npm install` would not actually crash, the error
+ // is merely logged to the console. To reproduce the error, we should make
+ // sure that script's install.js can be run subsequently without unhandled promise rejections.
+ // Note: the flag `--unhandled-rejections=strict` will force node to terminate in case
+ // of UnhandledPromiseRejection.
+ await exec('node --unhandled-rejections=strict', path.join('node_modules', '@playwright', 'browser-chromium', 'install.js'));
+});
diff --git a/tests/installation/playwright-cli-screenshot-should-work.spec.ts b/tests/installation/playwright-cli-screenshot-should-work.spec.ts
deleted file mode 100755
index 49d5beaf62..0000000000
--- a/tests/installation/playwright-cli-screenshot-should-work.spec.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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 { test } from './npmTest';
-import fs from 'fs';
-import path from 'path';
-
-test('playwright cli screenshot should work', async ({ exec, tmpWorkspace }) => {
- await exec('npm i --foreground-scripts playwright');
- await exec('npx playwright install chromium');
- await exec(path.join('node_modules', '.bin', 'playwright'), 'screenshot about:blank one.png');
- await fs.promises.stat(path.join(tmpWorkspace, 'one.png'));
-
- await exec('npx playwright screenshot about:blank two.png');
- await fs.promises.stat(path.join(tmpWorkspace, 'two.png'));
-});
diff --git a/tests/installation/playwright-cli-codegen.spec.ts b/tests/installation/playwright-cli.spec.ts
similarity index 76%
rename from tests/installation/playwright-cli-codegen.spec.ts
rename to tests/installation/playwright-cli.spec.ts
index 64657555b3..9b2b34cb74 100755
--- a/tests/installation/playwright-cli-codegen.spec.ts
+++ b/tests/installation/playwright-cli.spec.ts
@@ -14,9 +14,11 @@
* limitations under the License.
*/
import { test, expect } from './npmTest';
+import path from 'path';
+import fs from 'fs';
-test('codegen should work', async ({ exec }) => {
- await exec('npm i --foreground-scripts playwright');
+test('cli should work', async ({ exec, tmpWorkspace }) => {
+ await exec('npm i playwright');
await exec('npx playwright install chromium');
await test.step('codegen without arguments', async () => {
@@ -48,4 +50,12 @@ test('codegen should work', async ({ exec }) => {
});
expect(result).toContain(`browser.close`);
});
+
+ await test.step('screenshot', async () => {
+ await exec(path.join('node_modules', '.bin', 'playwright'), 'screenshot about:blank one.png');
+ await fs.promises.stat(path.join(tmpWorkspace, 'one.png'));
+
+ await exec('npx playwright screenshot about:blank two.png');
+ await fs.promises.stat(path.join(tmpWorkspace, 'two.png'));
+ });
});
diff --git a/tests/installation/playwright-core-should-work.spec.ts b/tests/installation/playwright-core-should-work.spec.ts
deleted file mode 100755
index 5fbad8cd9e..0000000000
--- a/tests/installation/playwright-core-should-work.spec.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test(`playwright-core should work`, async ({ exec, installedSoftwareOnDisk }) => {
- const result1 = await exec('npm i --foreground-scripts playwright-core');
- expect(result1).toHaveLoggedSoftwareDownload([]);
- expect(await installedSoftwareOnDisk()).toEqual([]);
- const stdio = await exec('npx playwright-core', 'test', '-c', '.', { expectToExitWithError: true });
- expect(stdio).toContain(`Please install @playwright/test package`);
-});
diff --git a/tests/installation/playwright-electron-should-work.spec.ts b/tests/installation/playwright-electron-should-work.spec.ts
index 6b7fdfbdcf..76cad12ec7 100755
--- a/tests/installation/playwright-electron-should-work.spec.ts
+++ b/tests/installation/playwright-electron-should-work.spec.ts
@@ -15,7 +15,12 @@
*/
import { test } from './npmTest';
-test('electron should work', async ({ exec }) => {
- await exec('npm i --foreground-scripts playwright [email protected]');
+test('electron should work', async ({ exec, tsc, writeFiles }) => {
+ await exec('npm i playwright [email protected]');
await exec('node sanity-electron.js');
+ await writeFiles({
+ 'test.ts':
+ `import { Page, _electron, ElectronApplication, Electron } from 'playwright';`
+ });
+ await tsc('test.ts');
});
diff --git a/tests/installation/playwright-global-installation-cross-package.spec.ts b/tests/installation/playwright-global-installation-cross-package.spec.ts
deleted file mode 100755
index 0f494d849a..0000000000
--- a/tests/installation/playwright-global-installation-cross-package.spec.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('global installation cross package', async ({ exec, installedSoftwareOnDisk }) => {
- const packages = ['playwright-chromium', 'playwright-firefox', 'playwright-webkit'];
- for (const pkg of packages)
- await exec('npm i --foreground-scripts', pkg, { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
- const result = await exec('npx playwright install');
- expect(result).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
- expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
-
- for (const pkg of packages)
- await test.step(pkg, () => exec('node sanity.js', pkg, 'chromium firefox webkit'));
-});
diff --git a/tests/installation/playwright-global-installation.spec.ts b/tests/installation/playwright-global-installation.spec.ts
deleted file mode 100755
index 438247d398..0000000000
--- a/tests/installation/playwright-global-installation.spec.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('global installation', async ({ exec, installedSoftwareOnDisk }) => {
- const result1 = await exec('npm i --foreground-scripts playwright');
- expect(result1).toHaveLoggedSoftwareDownload([]);
- expect(await installedSoftwareOnDisk()).toEqual([]);
-
- const result2 = await exec('npx playwright install');
- expect(result2).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
- expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
-
- await exec('node sanity.js playwright', { env: { PLAYWRIGHT_BROWSERS_PATH: undefined } });
- await exec('node sanity.js playwright chromium firefox webkit');
-});
diff --git a/tests/installation/playwright-global-subsequent-installs.spec.ts b/tests/installation/playwright-global-subsequent-installs.spec.ts
deleted file mode 100755
index 06dcda1ef9..0000000000
--- a/tests/installation/playwright-global-subsequent-installs.spec.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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 { test } from './npmTest';
-import path from 'path';
-
-test('subsequent installs works', async ({ exec }) => {
- test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/1651' });
- await exec('npm i --foreground-scripts @playwright/browser-chromium');
- // Note: the `npm install` would not actually crash, the error
- // is merely logged to the console. To reproduce the error, we should make
- // sure that script's install.js can be run subsequently without unhandled promise rejections.
- // Note: the flag `--unhandled-rejections=strict` will force node to terminate in case
- // of UnhandledPromiseRejection.
- await exec('node --unhandled-rejections=strict', path.join('node_modules', '@playwright', 'browser-chromium', 'install.js'));
-});
diff --git a/tests/installation/playwright-xyz-should-work.spec.ts b/tests/installation/playwright-packages-install-behavior.spec.ts
similarity index 50%
rename from tests/installation/playwright-xyz-should-work.spec.ts
rename to tests/installation/playwright-packages-install-behavior.spec.ts
index 5493ee942f..24d8c058a5 100755
--- a/tests/installation/playwright-xyz-should-work.spec.ts
+++ b/tests/installation/playwright-packages-install-behavior.spec.ts
@@ -16,6 +16,8 @@
*/
import { test, expect } from './npmTest';
+test.use({ isolateBrowsers: true });
+
for (const browser of ['chromium', 'firefox', 'webkit']) {
test(`playwright-${browser} should work`, async ({ exec, installedSoftwareOnDisk }) => {
const pkg = `playwright-${browser}`;
@@ -52,3 +54,46 @@ for (const browser of ['chromium', 'firefox', 'webkit']) {
await exec('node browser-only.js', pkg);
});
}
+
+test(`playwright-core should work`, async ({ exec, installedSoftwareOnDisk }) => {
+ const result1 = await exec('npm i --foreground-scripts playwright-core');
+ expect(result1).toHaveLoggedSoftwareDownload([]);
+ expect(await installedSoftwareOnDisk()).toEqual([]);
+ const stdio = await exec('npx playwright-core', 'test', '-c', '.', { expectToExitWithError: true });
+ expect(stdio).toContain(`Please install @playwright/test package`);
+});
+
+test(`playwright should work`, async ({ exec, installedSoftwareOnDisk }) => {
+ const result1 = await exec('npm i --foreground-scripts playwright');
+ expect(result1).toHaveLoggedSoftwareDownload([]);
+ expect(await installedSoftwareOnDisk()).toEqual([]);
+
+ const result2 = await exec('npx playwright install');
+ expect(result2).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
+ expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
+
+ await exec('node sanity.js playwright chromium firefox webkit');
+ await exec('node esm-playwright.mjs');
+});
+
+test('@playwright/test should work', async ({ exec, installedSoftwareOnDisk }) => {
+ const result1 = await exec('npm i --foreground-scripts @playwright/test');
+ expect(result1).toHaveLoggedSoftwareDownload([]);
+ expect(await installedSoftwareOnDisk()).toEqual([]);
+
+ await exec('npx playwright test -c . sample.spec.js', { expectToExitWithError: true, message: 'should not be able to run tests without installing browsers' });
+
+ const result2 = await exec('npx playwright install');
+ expect(result2).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
+ expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
+
+ await exec('node sanity.js @playwright/test chromium firefox webkit');
+ await exec('node', 'esm-playwright-test.mjs');
+
+ const result3 = await exec('npx playwright test -c . --browser=all --reporter=list sample.spec.js');
+ expect(result3).toContain('3 passed');
+
+ const result4 = await exec('npx playwright test -c . failing.spec.js', { expectToExitWithError: true, env: { DEBUG: 'pw:api' } });
+ expect(result4).toContain('expect.toHaveText started');
+ expect(result4).toContain('failing.spec.js:5:38');
+});
diff --git a/tests/installation/playwright-should-work-with-relative-browsers-path.spec.ts b/tests/installation/playwright-should-work-with-relative-browsers-path.spec.ts
index ef48d46527..e3fbd45542 100755
--- a/tests/installation/playwright-should-work-with-relative-browsers-path.spec.ts
+++ b/tests/installation/playwright-should-work-with-relative-browsers-path.spec.ts
@@ -20,7 +20,7 @@ import path from 'path';
test('playwright should work with relative home path', async ({ exec, tmpWorkspace }) => {
await fs.promises.mkdir(path.join(tmpWorkspace, 'foo'));
// Make sure that browsers path is resolved relative to the `npm install` call location.
- await exec('npm i --foreground-scripts playwright', { cwd: path.join(tmpWorkspace, 'foo'), env: { PLAYWRIGHT_BROWSERS_PATH: path.join('..', 'relative') } });
+ await exec('npm i playwright', { cwd: path.join(tmpWorkspace, 'foo'), env: { PLAYWRIGHT_BROWSERS_PATH: path.join('..', 'relative') } });
await exec('npx playwright install', { cwd: path.join(tmpWorkspace, 'foo'), env: { PLAYWRIGHT_BROWSERS_PATH: path.join('..', 'relative') } });
await exec('node sanity.js playwright chromium firefox webkit', { env: { PLAYWRIGHT_BROWSERS_PATH: path.join('.', 'relative') } });
});
diff --git a/tests/installation/playwright-should-work-with-relative-home-path.spec.ts b/tests/installation/playwright-should-work-with-relative-home-path.spec.ts
index b6295ede4c..db403f80cf 100755
--- a/tests/installation/playwright-should-work-with-relative-home-path.spec.ts
+++ b/tests/installation/playwright-should-work-with-relative-home-path.spec.ts
@@ -20,7 +20,7 @@ test('playwright should work with relative home path', async ({ exec }) => {
test.skip(os.platform().startsWith('win'));
const env = { PLAYWRIGHT_BROWSERS_PATH: '0', HOME: '.' };
- await exec('npm i --foreground-scripts playwright @playwright/browser-chromium @playwright/browser-webkit', { env });
+ await exec('npm i playwright @playwright/browser-chromium @playwright/browser-webkit', { env });
// Firefox does not work with relative HOME.
await exec('node sanity.js playwright chromium webkit', { env });
});
diff --git a/tests/installation/playwright-should-work.spec.ts b/tests/installation/playwright-should-work.spec.ts
deleted file mode 100755
index d57d691e7b..0000000000
--- a/tests/installation/playwright-should-work.spec.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test.use({ useRealCDN: true });
-
-test(`playwright should work`, async ({ exec, installedSoftwareOnDisk }) => {
- const result1 = await exec('npm i --foreground-scripts playwright');
- expect(result1).toHaveLoggedSoftwareDownload([]);
- expect(await installedSoftwareOnDisk()).toEqual([]);
-
- const result2 = await exec('npm i --foreground-scripts @playwright/browser-chromium @playwright/browser-firefox @playwright/browser-webkit');
- expect(result2).toHaveLoggedSoftwareDownload(['chromium', 'ffmpeg', 'firefox', 'webkit']);
- expect(await installedSoftwareOnDisk()).toEqual(['chromium', 'ffmpeg', 'firefox', 'webkit']);
-
- await exec('node sanity.js playwright chromium firefox webkit');
- await exec('node esm-playwright.mjs');
-});
diff --git a/tests/installation/playwright-test-should-work.spec.ts b/tests/installation/playwright-test-package-managers.spec.ts
similarity index 80%
rename from tests/installation/playwright-test-should-work.spec.ts
rename to tests/installation/playwright-test-package-managers.spec.ts
index ab6c3b9411..5d8af73ca4 100755
--- a/tests/installation/playwright-test-should-work.spec.ts
+++ b/tests/installation/playwright-test-package-managers.spec.ts
@@ -17,9 +17,7 @@ import { test } from './npmTest';
import path from 'path';
test('npm: @playwright/test should work', async ({ exec, tmpWorkspace }) => {
- await exec('npm i --foreground-scripts @playwright/test');
- await exec('npx playwright test -c . sample.spec.js', { expectToExitWithError: true, message: 'should not be able to run tests without installing browsers' });
-
+ await exec('npm i @playwright/test');
await exec('npx playwright install');
await exec('npx playwright test -c . --browser=all --reporter=list,json sample.spec.js', { env: { PLAYWRIGHT_JSON_OUTPUT_NAME: 'report.json' } });
await exec('node read-json-report.js', path.join(tmpWorkspace, 'report.json'));
@@ -28,8 +26,8 @@ test('npm: @playwright/test should work', async ({ exec, tmpWorkspace }) => {
});
test('npm: playwright + @playwright/test should work', async ({ exec, tmpWorkspace }) => {
- await exec('npm i --foreground-scripts playwright');
- await exec('npm i --foreground-scripts @playwright/test');
+ await exec('npm i playwright');
+ await exec('npm i @playwright/test');
await exec('npx playwright install');
await exec('npx playwright test -c . --browser=all --reporter=list,json sample.spec.js', { env: { PLAYWRIGHT_JSON_OUTPUT_NAME: 'report.json' } });
await exec('node read-json-report.js', path.join(tmpWorkspace, 'report.json'));
@@ -38,8 +36,8 @@ test('npm: playwright + @playwright/test should work', async ({ exec, tmpWorkspa
});
test('npm: @playwright/test + playwright-core should work', async ({ exec, tmpWorkspace }) => {
- await exec('npm i --foreground-scripts @playwright/test');
- await exec('npm i --foreground-scripts playwright-core');
+ await exec('npm i @playwright/test');
+ await exec('npm i playwright-core');
await exec('npx playwright install');
await exec('npx playwright test -c . --browser=all --reporter=list,json sample.spec.js', { env: { PLAYWRIGHT_JSON_OUTPUT_NAME: 'report.json' } });
await exec('node read-json-report.js', path.join(tmpWorkspace, 'report.json'));
@@ -49,8 +47,6 @@ test('npm: @playwright/test + playwright-core should work', async ({ exec, tmpWo
test('yarn: @playwright/test should work', async ({ exec, tmpWorkspace }) => {
await exec('yarn add @playwright/test');
- await exec('yarn playwright test -c .', { expectToExitWithError: true, message: 'should not be able to run tests without installing browsers' });
-
await exec('yarn playwright install');
await exec('yarn playwright test -c . --browser=all --reporter=list,json sample.spec.js', { env: { PLAYWRIGHT_JSON_OUTPUT_NAME: 'report.json' } });
await exec('node read-json-report.js', path.join(tmpWorkspace, 'report.json'));
@@ -60,7 +56,6 @@ test('yarn: @playwright/test should work', async ({ exec, tmpWorkspace }) => {
test('pnpm: @playwright/test should work', async ({ exec, tmpWorkspace }) => {
await exec('pnpm add @playwright/test');
- await exec('pnpm exec playwright test -c .', { expectToExitWithError: true, message: 'should not be able to run tests without installing browsers' });
await exec('pnpm exec playwright install');
await exec('pnpm exec playwright test -c . --browser=all --reporter=list,json sample.spec.js', { env: { PLAYWRIGHT_JSON_OUTPUT_NAME: 'report.json' } });
await exec('node read-json-report.js', path.join(tmpWorkspace, 'report.json'));
diff --git a/tests/installation/playwright-test-plugin.spec.ts b/tests/installation/playwright-test-plugin.spec.ts
index deadc94da5..3e9ddfb0e5 100755
--- a/tests/installation/playwright-test-plugin.spec.ts
+++ b/tests/installation/playwright-test-plugin.spec.ts
@@ -33,16 +33,16 @@ function patchPackageJsonForPreReleaseIfNeeded(tmpWorkspace: string) {
}
test('npm: @playwright/test plugin should work', async ({ exec, tmpWorkspace }) => {
- await exec('npm i --foreground-scripts @playwright/test');
+ await exec('npm i @playwright/test');
patchPackageJsonForPreReleaseIfNeeded(tmpWorkspace);
- await exec('npm i --foreground-scripts playwright-test-plugin');
+ await exec('npm i playwright-test-plugin');
await exec('npx playwright install chromium');
const output = await exec('npx playwright test -c . --browser=chromium --reporter=line plugin.spec.ts');
expect(output).toContain('plugin value: hello from plugin');
expect(output).toContain('1 passed');
- await exec('npm i --foreground-scripts [email protected] @types/node@16');
+ await exec('npm i [email protected] @types/node@16');
await exec('npx tsc playwright-test-plugin-types.ts');
});
diff --git a/tests/installation/playwright-test-stacks-should-work.spec.ts b/tests/installation/playwright-test-stacks-should-work.spec.ts
deleted file mode 100755
index 50b001ca96..0000000000
--- a/tests/installation/playwright-test-stacks-should-work.spec.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('@playwright/test stacks should work', async ({ exec }) => {
- await exec('npm i --foreground-scripts @playwright/test');
- await exec('npx playwright install chromium');
- const output = await exec('npx playwright test -c . failing.spec.js', { expectToExitWithError: true, env: { DEBUG: 'pw:api' } });
- expect(output).toContain('expect.toHaveText started');
- expect(output).toContain('failing.spec.js:5:38');
-});
diff --git a/tests/installation/screencast.spec.ts b/tests/installation/screencast.spec.ts
index 96ccbde981..9b12421f3c 100755
--- a/tests/installation/screencast.spec.ts
+++ b/tests/installation/screencast.spec.ts
@@ -16,8 +16,6 @@
import { test } from './npmTest';
test('screencast works', async ({ exec }) => {
- await exec('npm i --foreground-scripts', 'playwright', 'playwright-chromium', 'playwright-firefox', 'playwright-webkit');
- await test.step('playwright', () => exec('node screencast.js playwright chromium firefox webkit'));
- for (const browser of ['chromium', 'firefox', 'webkit'])
- await test.step(browser, () => exec(`node screencast.js playwright-${browser} ${browser}`));
+ await exec('npm i playwright');
+ await exec('node screencast.js playwright chromium firefox webkit');
});
diff --git a/tests/installation/skip-browser-download-inspect-with-custom-executable.spec.ts b/tests/installation/skip-browser-download-inspect-with-custom-executable.spec.ts
deleted file mode 100755
index 1a394d6a0f..0000000000
--- a/tests/installation/skip-browser-download-inspect-with-custom-executable.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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 { test, expect } from './npmTest';
-
-test('should skip download', async ({ exec }) => {
- const installOutput = await exec('npm i --foreground-scripts playwright @playwright/browser-chromium', { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
- expect(installOutput).toContain('Skipping browsers download because');
- if (process.platform === 'linux') {
- const output = await exec('node inspector-custom-executable.js', { env: { PWDEBUG: '1' } });
- expect(output).toContain('SUCCESS');
- }
-});
diff --git a/tests/installation/skip-browser-download.spec.ts b/tests/installation/skip-browser-download.spec.ts
index 98a016411d..7cf9cdf602 100755
--- a/tests/installation/skip-browser-download.spec.ts
+++ b/tests/installation/skip-browser-download.spec.ts
@@ -15,9 +15,16 @@
*/
import { test, expect } from './npmTest';
-test('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD should skip browser installs', async ({ exec, installedSoftwareOnDisk }) => {
- const result = await exec('npm i --foreground-scripts @playwright/browser-firefox', { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
+test.use({ isolateBrowsers: true });
+
+test('should skip browser installs', async ({ exec, installedSoftwareOnDisk }) => {
+ const result = await exec('npm i --foreground-scripts playwright @playwright/browser-firefox', { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
expect(result).toHaveLoggedSoftwareDownload([]);
expect(await installedSoftwareOnDisk()).toEqual([]);
expect(result).toContain(`Skipping browsers download because`);
+
+ if (process.platform === 'linux') {
+ const output = await exec('node inspector-custom-executable.js', { env: { PWDEBUG: '1' } });
+ expect(output).toContain('SUCCESS');
+ }
});
diff --git a/tests/installation/typescript-types.spec.ts b/tests/installation/typescript-types.spec.ts
index 139eec9925..34e5ccb0fd 100755
--- a/tests/installation/typescript-types.spec.ts
+++ b/tests/installation/typescript-types.spec.ts
@@ -31,28 +31,15 @@ test('typescript types should work', async ({ exec, tsc, writeFiles }) => {
[filename]: `import { Page } from '${libraryPackage}';`,
});
await tsc(filename);
- }
-
- await tsc('playwright-test-types.ts');
-});
-
-test('typescript types should work with module: NodeNext', async ({ exec, tsc, writeFiles }) => {
- const libraryPackages = [
- 'playwright',
- 'playwright-core',
- 'playwright-firefox',
- 'playwright-webkit',
- 'playwright-chromium',
- ];
- await exec('npm i @playwright/test', ...libraryPackages, { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
-
- for (const libraryPackage of libraryPackages) {
- const filename = libraryPackage + '.ts';
- await writeFiles({
- [filename]: `import { Page } from '${libraryPackage}';`,
- });
await tsc(`--module nodenext ${filename}`);
}
+ await tsc('playwright-test-types.ts');
await tsc('--module nodenext playwright-test-types.ts');
+
+ await writeFiles({
+ 'test.ts':
+ `import { AndroidDevice, _android, AndroidWebView, Page } from 'playwright';`,
+ });
+ await tsc('test.ts');
});
diff --git a/tests/installation/validate-dependencies.spec.ts b/tests/installation/validate-dependencies.spec.ts
index f68eb84ee3..247628c307 100644
--- a/tests/installation/validate-dependencies.spec.ts
+++ b/tests/installation/validate-dependencies.spec.ts
@@ -15,18 +15,17 @@
*/
import { test, expect } from './npmTest';
-test.describe('validate dependencies', () => {
- test('default (on)', async ({ exec }) => {
- await exec('npm i --foreground-scripts playwright');
- await exec('npx playwright install chromium');
- const result = await exec('node validate-dependencies.js');
- expect(result).toContain(`PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS`);
+test('validate dependencies', async ({ exec }) => {
+ await exec('npm i playwright');
+ await exec('npx playwright install chromium');
+
+ await test.step('default (on)', async () => {
+ const result1 = await exec('node validate-dependencies.js');
+ expect(result1).toContain(`PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS`);
});
- test('disabled (off)', async ({ exec }) => {
- await exec('npm i --foreground-scripts playwright');
- await exec('npx playwright install chromium');
- const result = await exec('node validate-dependencies-skip-executable-path.js');
- expect(result).not.toContain(`PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS`);
+ await test.step('disabled (off)', async () => {
+ const result2 = await exec('node validate-dependencies-skip-executable-path.js');
+ expect(result2).not.toContain(`PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS`);
});
});