playwright.config.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/ },
  48. {
  49. name: 'chromium',
  50. use: { ...devices['Desktop Chrome'] },
  51. dependencies: ['setup'],
  52. },
  53. {
  54. name: 'firefox',
  55. use: { ...devices['Desktop Firefox'] },
  56. dependencies: ['setup'],
  57. },
  58. {
  59. name: 'webkit',
  60. use: { ...devices['Desktop Safari'] },
  61. dependencies: ['setup'],
  62. },
  63. /* Test against mobile viewports. */
  64. // {
  65. // name: 'Mobile Chrome',
  66. // use: { ...devices['Pixel 5'] },
  67. // },
  68. // {
  69. // name: 'Mobile Safari',
  70. // use: { ...devices['iPhone 12'] },
  71. // },
  72. /* Test against branded browsers. */
  73. // {
  74. // name: 'Microsoft Edge',
  75. // use: { ...devices['Desktop Edge'], channel: 'msedge' },
  76. // },
  77. // {
  78. // name: 'Google Chrome',
  79. // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
  80. // },
  81. ],
  82. });