playwright.config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @ts-check
  2. import { defineConfig, devices } from '@playwright/test';
  3. /**
  4. * Read environment variables from file.
  5. * https://github.com/motdotla/dotenv
  6. */
  7. // import dotenv from 'dotenv';
  8. // import path from 'path';
  9. // dotenv.config({ path: path.resolve(__dirname, '.env') });
  10. /**
  11. * @see https://playwright.dev/docs/test-configuration
  12. */
  13. export default defineConfig({
  14. testDir: './playwright-tests',
  15. /* Run tests in files in parallel */
  16. fullyParallel: false,
  17. /* Fail the build on CI if you accidentally left test.only in the source code. */
  18. forbidOnly: !!process.env.CI,
  19. /* Retry on CI only */
  20. retries: process.env.CI ? 2 : 0,
  21. /* Opt out of parallel tests on CI. */
  22. workers: process.env.CI ? 1 : undefined,
  23. /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  24. reporter: 'list',
  25. /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  26. use: {
  27. /* Base URL to use in actions like `await page.goto('/')`. */
  28. // baseURL: 'http://127.0.0.1:3000/playwright-page',
  29. /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
  30. trace: 'on-first-retry',
  31. },
  32. /* Configure projects for major browsers */
  33. projects: [
  34. {
  35. name: 'chromium',
  36. use: { ...devices['Desktop Chrome'] },
  37. },
  38. // {
  39. // name: 'firefox',
  40. // use: { ...devices['Desktop Firefox'] },
  41. // },
  42. // {
  43. // name: 'webkit',
  44. // use: { ...devices['Desktop Safari'] },
  45. // },
  46. /* Test against mobile viewports. */
  47. // {
  48. // name: 'Mobile Chrome',
  49. // use: { ...devices['Pixel 5'] },
  50. // },
  51. // {
  52. // name: 'Mobile Safari',
  53. // use: { ...devices['iPhone 12'] },
  54. // },
  55. /* Test against branded browsers. */
  56. // {
  57. // name: 'Microsoft Edge',
  58. // use: { ...devices['Desktop Edge'], channel: 'msedge' },
  59. // },
  60. // {
  61. // name: 'Google Chrome',
  62. // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
  63. // },
  64. ],
  65. /* Run your local dev server before starting the tests */
  66. webServer: {
  67. command: 'npm run test:playwright:setup',
  68. url: 'http://127.0.0.1:3333',
  69. reuseExistingServer: !process.env.CI,
  70. },
  71. });