playwright.config.ts 3.2 KB

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