Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

54 Zeilen
1.5 KiB

  1. import { defineConfig, devices } from '@playwright/test'
  2. import fs from 'node:fs'
  3. import path from 'node:path'
  4. const loadLocalEnvironment = () => {
  5. const filename = process.env.E2E_ENV_FILE?.trim() || path.resolve('.env')
  6. if (!fs.existsSync(filename)) return
  7. for (const line of fs.readFileSync(filename, 'utf8').split(/\r?\n/)) {
  8. const match = line.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/)
  9. if (!match || match[1]!.startsWith('#') || process.env[match[1]!]) continue
  10. const raw = match[2]!
  11. process.env[match[1]!] = raw.length >= 2 && ((raw.startsWith('"') && raw.endsWith('"')) || (raw.startsWith("'") && raw.endsWith("'")))
  12. ? raw.slice(1, -1)
  13. : raw
  14. }
  15. }
  16. loadLocalEnvironment()
  17. const baseURL = (process.env.BASE_URL ?? 'http://127.0.0.1:6180').replace(/\/$/, '')
  18. export default defineConfig({
  19. testDir: './tests',
  20. outputDir: './artifacts/test-results',
  21. fullyParallel: false,
  22. workers: 1,
  23. retries: process.env.CI ? 1 : 0,
  24. timeout: 60_000,
  25. expect: {
  26. timeout: 10_000,
  27. },
  28. reporter: [
  29. ['list'],
  30. ['html', { outputFolder: 'artifacts/html-report', open: 'never' }],
  31. ['json', { outputFile: 'artifacts/results.json' }],
  32. ],
  33. use: {
  34. baseURL,
  35. locale: 'zh-CN',
  36. timezoneId: 'Asia/Shanghai',
  37. actionTimeout: 10_000,
  38. navigationTimeout: 20_000,
  39. screenshot: 'off',
  40. trace: 'retain-on-failure',
  41. video: 'retain-on-failure',
  42. },
  43. projects: [
  44. {
  45. name: 'chromium',
  46. use: { ...devices['Desktop Chrome'] },
  47. },
  48. ],
  49. })