playwright.config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // @ts-check
  2. const { defineConfig, devices } = require("@playwright/test");
  3. const path = require("path");
  4. /**
  5. * Read environment variables from file.
  6. * https://github.com/motdotla/dotenv
  7. */
  8. // require('dotenv').config();
  9. const runDxCmd = process.env.CI
  10. ? "cargo run --package dioxus-cli --release -- "
  11. : "target/release/dx";
  12. /**
  13. * @see https://playwright.dev/docs/test-configuration
  14. */
  15. module.exports = defineConfig({
  16. testDir: ".",
  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. workers: 8,
  26. /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  27. reporter: "html",
  28. /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  29. use: {
  30. /* Base URL to use in actions like `await page.goto('/')`. */
  31. // baseURL: 'http://127.0.0.1:3000',
  32. /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
  33. trace: "on-first-retry",
  34. // Increase the timeout for navigations to give dx time to build the project
  35. navigationTimeout: 50 * 60 * 1000,
  36. },
  37. timeout: 50 * 60 * 1000,
  38. /* Configure projects for major browsers */
  39. projects: [
  40. {
  41. name: "chromium",
  42. use: { ...devices["Desktop Chrome"] },
  43. },
  44. // {
  45. // name: 'firefox',
  46. // use: { ...devices['Desktop Firefox'] },
  47. // },
  48. // {
  49. // name: 'webkit',
  50. // use: { ...devices['Desktop Safari'] },
  51. // },
  52. /* Test against mobile viewports. */
  53. // {
  54. // name: 'Mobile Chrome',
  55. // use: { ...devices['Pixel 5'] },
  56. // },
  57. // {
  58. // name: 'Mobile Safari',
  59. // use: { ...devices['iPhone 12'] },
  60. // },
  61. /* Test against branded browsers. */
  62. // {
  63. // name: 'Microsoft Edge',
  64. // use: { ...devices['Desktop Edge'], channel: 'msedge' },
  65. // },
  66. // {
  67. // name: 'Google Chrome',
  68. // use: { ..devices['Desktop Chrome'], channel: 'chrome' },
  69. // },
  70. ],
  71. /* Run your local dev server before starting the tests */
  72. webServer: [
  73. {
  74. command:
  75. "cargo run --package dioxus-playwright-liveview-test --bin dioxus-playwright-liveview-test",
  76. port: 3030,
  77. timeout: 50 * 60 * 1000,
  78. reuseExistingServer: !process.env.CI,
  79. stdout: "pipe",
  80. },
  81. {
  82. cwd: path.join(process.cwd(), "web"),
  83. command:
  84. runDxCmd +
  85. 'serve --force-sequential --platform web --addr "127.0.0.1" --port 9999',
  86. port: 9999,
  87. timeout: 50 * 60 * 1000,
  88. reuseExistingServer: !process.env.CI,
  89. stdout: "pipe",
  90. },
  91. {
  92. cwd: path.join(process.cwd(), "fullstack"),
  93. command:
  94. runDxCmd +
  95. 'serve --force-sequential --platform web --addr "127.0.0.1" --port 3333',
  96. port: 3333,
  97. timeout: 50 * 60 * 1000,
  98. reuseExistingServer: !process.env.CI,
  99. stdout: "pipe",
  100. },
  101. {
  102. cwd: path.join(process.cwd(), "fullstack-mounted"),
  103. command:
  104. runDxCmd +
  105. 'serve --force-sequential --platform web --addr "127.0.0.1" --port 7777',
  106. port: 7777,
  107. timeout: 50 * 60 * 1000,
  108. reuseExistingServer: !process.env.CI,
  109. stdout: "pipe",
  110. },
  111. {
  112. cwd: path.join(process.cwd(), "suspense-carousel"),
  113. command:
  114. runDxCmd +
  115. 'serve --force-sequential --platform web --addr "127.0.0.1" --port 4040',
  116. port: 4040,
  117. timeout: 50 * 60 * 1000,
  118. reuseExistingServer: !process.env.CI,
  119. stdout: "pipe",
  120. },
  121. {
  122. cwd: path.join(process.cwd(), "nested-suspense"),
  123. command:
  124. runDxCmd +
  125. 'serve --force-sequential --platform web --addr "127.0.0.1" --port 5050',
  126. port: 5050,
  127. timeout: 50 * 60 * 1000,
  128. reuseExistingServer: !process.env.CI,
  129. stdout: "pipe",
  130. },
  131. {
  132. cwd: path.join(process.cwd(), "nested-suspense"),
  133. command:
  134. runDxCmd +
  135. 'serve --bin nested-suspense-ssg --force-sequential --platform web --ssg --addr "127.0.0.1" --port 6060',
  136. port: 6060,
  137. timeout: 50 * 60 * 1000,
  138. reuseExistingServer: !process.env.CI,
  139. stdout: "pipe",
  140. },
  141. {
  142. cwd: path.join(process.cwd(), "cli-optimization"),
  143. // Remove the cache folder for the cli-optimization build to force a full cache reset
  144. command: runDxCmd + 'serve --addr "127.0.0.1" --port 8989',
  145. port: 8989,
  146. timeout: 50 * 60 * 1000,
  147. reuseExistingServer: !process.env.CI,
  148. stdout: "pipe",
  149. },
  150. ],
  151. });