playwright.config.ts 2.5 KB

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