playwright/tests/bidi/playwright.config.ts
Yury Semikhatsky 9a2c60a77c
chore: identify largest gaps in Bidi API (#32434)
This pull request introduces initial support for the WebDriver BiDi
protocol in Playwright. The primary goal of this PR is not to fully
implement BiDi but to experiment with the current state of the
specification and its implementation. We aim to identify the biggest
gaps and challenges that need to be addressed before considering BiDi as
the main protocol for Playwright.
2024-09-04 11:36:52 -07:00

96 lines
2.9 KiB
TypeScript

/**
* 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 { config as loadEnv } from 'dotenv';
loadEnv({ path: path.join(__dirname, '..', '..', '.env'), override: true });
import { type Config, type PlaywrightTestOptions, type PlaywrightWorkerOptions, type ReporterDescription } from '@playwright/test';
import * as path from 'path';
import type { TestModeWorkerOptions } from '../config/testModeFixtures';
const getExecutablePath = () => {
return process.env.BIDIPATH;
};
const headed = process.argv.includes('--headed');
const channel = process.env.PWTEST_CHANNEL as any;
const trace = !!process.env.PWTEST_TRACE;
const outputDir = path.join(__dirname, '..', '..', 'test-results');
const testDir = path.join(__dirname, '..');
const reporters = () => {
const result: ReporterDescription[] = process.env.CI ? [
['dot'],
['json', { outputFile: path.join(outputDir, 'report.json') }],
['blob', { fileName: `${process.env.PWTEST_BOT_NAME}.zip` }],
] : [
['html', { open: 'on-failure' }]
];
return result;
};
const config: Config<PlaywrightWorkerOptions & PlaywrightTestOptions & TestModeWorkerOptions> = {
testDir,
outputDir,
expect: {
timeout: 10000,
},
maxFailures: 200,
timeout: 30000,
globalTimeout: 5400000,
workers: process.env.CI ? 2 : undefined,
fullyParallel: !process.env.CI,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 3 : 0,
reporter: reporters(),
projects: [],
};
const browserName: any = '_experimentalBidi';
const executablePath = getExecutablePath();
if (executablePath && !process.env.TEST_WORKER_INDEX)
console.error(`Using executable at ${executablePath}`);
const testIgnore: RegExp[] = [];
for (const folder of ['library', 'page']) {
config.projects.push({
name: `${browserName}-${folder}`,
testDir: path.join(testDir, folder),
testIgnore,
snapshotPathTemplate: `{testDir}/{testFileDir}/{testFileName}-snapshots/{arg}-${browserName}{ext}`,
use: {
browserName,
headless: !headed,
channel,
video: 'off',
launchOptions: {
channel: 'bidi-firefox-stable',
executablePath,
},
trace: trace ? 'on' : undefined,
},
metadata: {
platform: process.platform,
docker: !!process.env.INSIDE_DOCKER,
headless: !headed,
browserName,
channel,
trace: !!trace,
},
});
}
export default config;