playwright.config.ts 2.4 KB

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