Skip to content

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

2.2 KB
Raw Blame
/**
 * 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'), quiet: true });
process.env.PWTEST_UNDER_TEST = '1';

import { defineConfig, type ReporterDescription } from './stable-test-runner';
import * as path from 'path';

const reporters = () => {
  const result: ReporterDescription[] = process.env.CI ? [
    ['dot'],
    ['blob', { outputDir: path.join(__dirname, '..', '..', 'blob-report') }],
    ['../config/parquetReporter.ts'],
  ] : [
    ['list']
  ];
  if (process.env.PWTEST_COVERAGE)
    result.push(['coverage', { outputDir: path.join(__dirname, '..', '..', 'coverage', 'html-reporter') }]);
  if (process.env.PW_BUN)
    result.push(['../config/expectationReporter', { expectationsFile: path.join(__dirname, 'bun-expectations.conf') }]);
  return result;
};
export default defineConfig({
  timeout: 30000,
  use: {
    // Coverage of the html reporter and trace viewer pages, built with PWTEST_COVERAGE=1.
    trace: process.env.PWTEST_COVERAGE ? { mode: 'on', snapshots: false, screenshots: false, _coverage: true } as any : 'off',
  },
  forbidOnly: !!process.env.CI,
  globalSetup: process.env.PW_BUN ? './current-test-runner/globalSetup.ts' : undefined,
  workers: undefined,
  snapshotPathTemplate: '__screenshots__/{testFilePath}/{arg}{ext}',
  projects: [
    {
      name: 'playwright-test',
      testDir: __dirname,
      testIgnore: ['assets/**', 'stable-test-runner/**'],
    },
    {
      name: 'image_tools',
      testDir: path.join(__dirname, '../image_tools'),
      testIgnore: [path.join(__dirname, '../fixtures/**')],
    }
  ],
  reporter: reporters(),
  tag: process.env.PW_TAG,
  metadata: {},
});