playwright.config.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { defineConfig, devices } from '@playwright/test';
  2. /**
  3. * Read environment variables from file.
  4. * https://github.com/motdotla/dotenv
  5. */
  6. // require('dotenv').config();
  7. /**
  8. * See https://playwright.dev/docs/test-configuration.
  9. */
  10. export default defineConfig({
  11. testDir: './playwright',
  12. outputDir: './playwright/output',
  13. /* Run tests in files in parallel */
  14. fullyParallel: true,
  15. /* Fail the build on CI if you accidentally left test.only in the source code. */
  16. forbidOnly: !!process.env.CI,
  17. /* Retry on CI only */
  18. retries: process.env.CI ? 2 : 0,
  19. /* Opt out of parallel tests on CI. */
  20. workers: process.env.CI ? 1 : undefined,
  21. /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  22. reporter: process.env.CI ? 'github' : 'list',
  23. webServer: {
  24. command: 'yarn server',
  25. url: 'http://localhost:3000',
  26. reuseExistingServer: !process.env.CI,
  27. stdout: 'ignore',
  28. stderr: 'pipe',
  29. },
  30. /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  31. use: {
  32. /* Base URL to use in actions like `await page.goto('/')`. */
  33. baseURL: 'http://localhost:3000',
  34. /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
  35. trace: 'on-first-retry',
  36. // Use prepared auth state.
  37. storageState: 'playwright/.auth/user.json',
  38. },
  39. /* Configure projects for major browsers */
  40. projects: [
  41. // Setup project
  42. { name: 'setup', testMatch: /.*\.setup\.ts/ },
  43. {
  44. name: 'chromium',
  45. use: { ...devices['Desktop Chrome'] },
  46. dependencies: ['setup'],
  47. },
  48. {
  49. name: 'firefox',
  50. use: { ...devices['Desktop Firefox'] },
  51. dependencies: ['setup'],
  52. },
  53. {
  54. name: 'webkit',
  55. use: { ...devices['Desktop Safari'] },
  56. dependencies: ['setup'],
  57. },
  58. /* Test against mobile viewports. */
  59. // {
  60. // name: 'Mobile Chrome',
  61. // use: { ...devices['Pixel 5'] },
  62. // },
  63. // {
  64. // name: 'Mobile Safari',
  65. // use: { ...devices['iPhone 12'] },
  66. // },
  67. /* Test against branded browsers. */
  68. // {
  69. // name: 'Microsoft Edge',
  70. // use: { ...devices['Desktop Edge'], channel: 'msedge' },
  71. // },
  72. // {
  73. // name: 'Google Chrome',
  74. // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
  75. // },
  76. ],
  77. /* Run your local dev server before starting the tests */
  78. // webServer: {
  79. // command: 'npm run start',
  80. // url: 'http://127.0.0.1:3000',
  81. // reuseExistingServer: !process.env.CI,
  82. // },
  83. });