playwright.config.ts 2.9 KB

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