playwright.config.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /// <reference types="node" />
  20. // eslint-disable-next-line import/no-extraneous-dependencies
  21. import { defineConfig } from '@playwright/test';
  22. export default defineConfig({
  23. // Test directory
  24. testDir: './playwright/tests',
  25. // Timeout settings
  26. timeout: 30000,
  27. expect: { timeout: 8000 },
  28. // Parallel execution
  29. fullyParallel: true,
  30. workers: process.env.CI ? 2 : 1,
  31. // Retry logic - 2 retries in CI, 0 locally
  32. retries: process.env.CI ? 2 : 0,
  33. // Reporter configuration - multiple reporters for better visibility
  34. reporter: process.env.CI
  35. ? [
  36. ['github'], // GitHub Actions annotations
  37. ['list'], // Detailed output with summary table
  38. ['html', { outputFolder: 'playwright-report', open: 'never' }], // Interactive report
  39. ['json', { outputFile: 'test-results/results.json' }], // Machine-readable
  40. ]
  41. : [
  42. ['list'], // Shows summary table locally
  43. ['html', { outputFolder: 'playwright-report', open: 'on-failure' }], // Auto-open on failure
  44. ],
  45. // Global test setup
  46. use: {
  47. // Use environment variable for base URL in CI, default to localhost:8088 for local
  48. baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:8088',
  49. // Browser settings
  50. headless: !!process.env.CI,
  51. viewport: { width: 1280, height: 1024 },
  52. // Screenshots and videos on failure
  53. screenshot: 'only-on-failure',
  54. video: 'retain-on-failure',
  55. // Trace collection for debugging
  56. trace: 'retain-on-failure',
  57. },
  58. projects: [
  59. {
  60. name: 'chromium',
  61. use: {
  62. browserName: 'chromium',
  63. testIdAttribute: 'data-test',
  64. },
  65. },
  66. ],
  67. // Web server setup - disabled in CI (Flask started separately in workflow)
  68. webServer: process.env.CI
  69. ? undefined
  70. : {
  71. command: 'curl -f http://localhost:8088/health',
  72. url: 'http://localhost:8088/health',
  73. reuseExistingServer: true,
  74. timeout: 5000,
  75. },
  76. });