nx/nx-dev/nx-dev-e2e/playwright.config.ts

41 lines
1.5 KiB
TypeScript

import { defineConfig } from '@playwright/test';
import { nxE2EPreset } from '@nx/playwright/preset';
import { workspaceRoot } from '@nx/devkit';
// For CI, you may want to set BASE_URL to the deployed application.
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
const preset = nxE2EPreset(__filename, { testDir: './src' });
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
...preset,
// CI default is 'dot', which doesn't show error output in CI.
// use list so errors are visible in CI logs
reporter: process.env.CI ? 'list' : preset.reporter,
// how long the entire suite can run, prevent CI from timing out
globalTimeout: process.env.CI ? 1_800_000 : undefined,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL,
// how long each page.goto can take before timing out
navigationTimeout: process.env.CI ? 30_000 : undefined,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm exec nx run nx-dev:serve:production',
url: 'http://localhost:4200',
reuseExistingServer: !process.env.CI,
cwd: workspaceRoot,
},
});