playwright.config.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { defineConfig, devices } from "@playwright/test";
  2. /**
  3. * Read environment variables from file.
  4. * https://github.com/motdotla/dotenv
  5. */
  6. // import dotenv from 'dotenv';
  7. // import path from 'path';
  8. // dotenv.config({ path: path.resolve(__dirname, '.env') });
  9. /**
  10. * See https://playwright.dev/docs/test-configuration.
  11. */
  12. export default defineConfig({
  13. testDir: "./tests",
  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: "html",
  24. /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  25. use: {
  26. /* Base URL to use in actions like `await page.goto('/')`. */
  27. baseURL: "http://localhost:3001/",
  28. /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
  29. trace: "on-first-retry",
  30. },
  31. /* Configure projects for major browsers */
  32. projects: [
  33. {
  34. name: "chromium",
  35. use: { ...devices["Desktop Chrome"] },
  36. },
  37. {
  38. name: "firefox",
  39. use: { ...devices["Desktop Firefox"] },
  40. },
  41. {
  42. name: "webkit",
  43. use: { ...devices["Desktop Safari"] },
  44. },
  45. /* Test against mobile viewports. */
  46. // {
  47. // name: 'Mobile Chrome',
  48. // use: { ...devices['Pixel 5'] },
  49. // },
  50. // {
  51. // name: 'Mobile Safari',
  52. // use: { ...devices['iPhone 12'] },
  53. // },
  54. /* Test against branded browsers. */
  55. // {
  56. // name: 'Microsoft Edge',
  57. // use: { ...devices['Desktop Edge'], channel: 'msedge' },
  58. // },
  59. // {
  60. // name: 'Google Chrome',
  61. // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
  62. // },
  63. ],
  64. /* Run your local dev server before starting the tests */
  65. webServer: {
  66. command: "npm run dev:mock -- --port 3001",
  67. url: "http://localhost:3001/",
  68. reuseExistingServer: !process.env.CI,
  69. },
  70. });