playwright.config.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { defineConfig, devices } from '@playwright/test';
  2. const isCI = !!process.env.CI;
  3. const baseUrl = process.env.BASE_URL || 'http://localhost:5050';
  4. const useWebServer = process.env.NO_WEB_SERVER !== 'true';
  5. /**
  6. * See https://playwright.dev/docs/test-configuration.
  7. */
  8. export default defineConfig({
  9. testDir: './src',
  10. testMatch: /\.e2e\.(spec\.)?ts$/,
  11. /* Run tests in files in parallel */
  12. fullyParallel: true,
  13. /* Fail the build on CI if you accidentally left test.only in the source code. */
  14. forbidOnly: isCI,
  15. /* Retry on CI only */
  16. retries: isCI ? 2 : 0,
  17. /* Opt out of parallel tests on CI. */
  18. workers: isCI ? 1 : undefined,
  19. /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  20. reporter: 'html',
  21. /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  22. use: {
  23. /* Base URL to use in actions like `await page.goto('/')`. */
  24. baseURL: baseUrl,
  25. /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
  26. trace: 'on-first-retry',
  27. testIdAttribute: 'data-test-id',
  28. locale: 'en-GB',
  29. timezoneId: 'Europe/Paris',
  30. },
  31. /* Configure projects for major browsers */
  32. projects: [
  33. {
  34. name: 'chromium',
  35. use: { ...devices['Desktop Chrome'] },
  36. },
  37. {
  38. name: 'firefox',
  39. use: { ...devices['Desktop Firefox'] },
  40. },
  41. {
  42. name: 'webkit',
  43. use: { ...devices['Desktop Safari'] },
  44. },
  45. ],
  46. /* Run your local dev server before starting the tests */
  47. ...(useWebServer
  48. && {
  49. webServer: {
  50. command: 'npm run preview',
  51. url: 'http://localhost:5050',
  52. reuseExistingServer: !isCI,
  53. },
  54. }
  55. ),
  56. });