playwright.config.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import type { PlaywrightTestConfig } from '@playwright/test';
  2. import { devices } from '@playwright/test';
  3. /**
  4. * Read environment variables from file.
  5. * https://github.com/motdotla/dotenv
  6. */
  7. // require('dotenv').config();
  8. /**
  9. * See https://playwright.dev/docs/test-configuration.
  10. */
  11. const config: PlaywrightTestConfig = {
  12. expect: {
  13. /**
  14. * Maximum time expect() should wait for the condition to be met.
  15. * For example in `await expect(locator).toHaveText();`
  16. */
  17. timeout: 5000,
  18. },
  19. /* Fail the build on CI if you accidentally left test.only in the source code. */
  20. forbidOnly: !!process.env.CI,
  21. /* Folder for test artifacts such as screenshots, videos, traces, etc. */
  22. outputDir: 'node_modules/.e2e/test-results/',
  23. /* Configure projects for major browsers */
  24. projects: [
  25. {
  26. name: 'chromium',
  27. use: {
  28. ...devices['Desktop Chrome'],
  29. },
  30. },
  31. // {
  32. // name: 'firefox',
  33. // use: {
  34. // ...devices['Desktop Firefox'],
  35. // },
  36. // },
  37. // {
  38. // name: 'webkit',
  39. // use: {
  40. // ...devices['Desktop Safari'],
  41. // },
  42. // },
  43. /* Test against mobile viewports. */
  44. // {
  45. // name: 'Mobile Chrome',
  46. // use: {
  47. // ...devices['Pixel 5'],
  48. // },
  49. // },
  50. // {
  51. // name: 'Mobile Safari',
  52. // use: {
  53. // ...devices['iPhone 12'],
  54. // },
  55. // },
  56. /* Test against branded browsers. */
  57. // {
  58. // name: 'Microsoft Edge',
  59. // use: {
  60. // channel: 'msedge',
  61. // },
  62. // },
  63. // {
  64. // name: 'Google Chrome',
  65. // use: {
  66. // channel: 'chrome',
  67. // },
  68. // },
  69. ],
  70. /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  71. reporter: [
  72. ['list'],
  73. ['html', { outputFolder: 'node_modules/.e2e/test-results' }],
  74. ],
  75. /* Retry on CI only */
  76. retries: process.env.CI ? 2 : 0,
  77. testDir: './__tests__/e2e',
  78. /* Maximum time one test can run for. */
  79. timeout: 30 * 1000,
  80. /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  81. use: {
  82. /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
  83. actionTimeout: 0,
  84. /* Base URL to use in actions like `await page.goto('/')`. */
  85. baseURL: 'http://localhost:5555',
  86. /* Only on CI systems run the tests headless */
  87. headless: !!process.env.CI,
  88. /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
  89. trace: 'retain-on-failure',
  90. },
  91. /* Run your local dev server before starting the tests */
  92. webServer: {
  93. command: process.env.CI ? 'pnpm preview --port 5555' : 'pnpm dev',
  94. port: 5555,
  95. reuseExistingServer: !process.env.CI,
  96. },
  97. /* Opt out of parallel tests on CI. */
  98. workers: process.env.CI ? 1 : undefined,
  99. };
  100. export default config;