playwright.config.ts 3.0 KB

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