Skip to content

Configure Playwright reporting for CI#122

Merged
shayancoin merged 3 commits intomainfrom
codex/add-playwright-configuration-for-ci
Oct 18, 2025
Merged

Configure Playwright reporting for CI#122
shayancoin merged 3 commits intomainfrom
codex/add-playwright-configuration-for-ci

Conversation

@shayancoin
Copy link
Owner

@shayancoin shayancoin commented Oct 16, 2025

Summary

  • add a root Playwright configuration mirroring the required timeout, parallelism, headless setting, and reporters
  • reuse the shared configuration from the frontend project and ignore generated artifacts

Testing

  • npx playwright test --list

https://chatgpt.com/codex/tasks/task_e_68f135b0bce483308c4a3ab2a42d4f4a

Summary by CodeRabbit

  • New Features

    • Added a dedicated Playwright test configuration to standardize end-to-end test behavior and reporting.
  • Chores

    • Updated testing infrastructure setup and streamlined test config exports.
    • Refined build artifact ignore patterns to exclude generated test outputs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a root Playwright config with dynamic runtime import and test settings, updates frontend/playwright.config.ts to re-export that config, and adds artifacts/ to .gitignore.

Changes

Cohort / File(s) Summary
Ignore list
\.gitignore
Added artifacts/ to the Node/Next.js ignore group.
Root Playwright config
playwright.config.ts
New file: defines testDir frontend/tests/e2e, test timeout 60s, expect timeout 15s, reporters (list, junitartifacts/junit.xml), use options (baseURL from env or http://localhost:3000, headless, trace on failure), launchOptions flags, and performs a dynamic runtime import/require for Playwright typings; exports config via defineConfig.
Frontend Playwright re-export
frontend/playwright.config.ts
Replaced inline defineConfig({...}) export with a default re-export of the root playwright.config.ts config object.

Sequence Diagram(s)

sequenceDiagram
  participant Developer
  participant PlaywrightTest as Playwright Test Runner
  participant RootConfig as playwright.config.ts
  participant FrontendConfig as frontend/playwright.config.ts
  Note over RootConfig: dynamic require/import of Playwright typings

  Developer->>PlaywrightTest: run tests
  PlaywrightTest->>FrontendConfig: import default config
  FrontendConfig->>RootConfig: re-exported config reference
  RootConfig->>PlaywrightTest: supplies config (baseURL, reporters, timeouts, use/launchOptions)
  PlaywrightTest->>PlaywrightTest: execute tests with configured options
  PlaywrightTest-->>Developer: emit results (JUnit -> artifacts/junit.xml)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰
I nibble on configs, tidy the trail,
Root hops in, front-end follows the trail,
Artifacts hidden, JUnit blooms bright,
Tests scurry onward into the night! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description does not follow the repository’s PR template: it is missing the PR Type section and the required Short Description and Tests Added headings, instead using generic Summary and Testing sections. As a result, it is unclear how the PR is classified and which tests were added under the correct template headings. This lack of adherence to the template reduces consistency and makes important information harder to locate. Please update the pull request description to include the PR Type heading, rename Summary to Short Description, add a Tests Added section listing any new or updated tests, and follow the exact structure and headings defined in the repository template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes configuring Playwright reporting for CI, which aligns with the pull request’s introduction of reporter settings and CI-specific test configuration. It clearly references the CI environment and the reporting feature introduced by the new configuration files. While it does not enumerate every change such as timeouts or headless mode, it focuses on a central aspect of the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Docstrings were successfully generated.
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-playwright-configuration-for-ci

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines 10 to 12
export default defineConfig({
testDir: 'frontend/tests/e2e',
timeout: 60_000,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use absolute testDir when exporting config to frontend

The new root Playwright config sets testDir: 'frontend/tests/e2e'. When the frontend’s playwright.config.ts re‑exports this config, Playwright resolves that relative path from the frontend directory, yielding frontend/frontend/tests/e2e and causing npm run test:e2e to fail with no tests found. Consider resolving the test directory from the repo root (e.g., resolve(__dirname, 'frontend/tests/e2e')) or overriding it when the config is consumed from the frontend so that existing frontend scripts continue to work.

Useful? React with 👍 / 👎.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2a35c4 and fce5765.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • frontend/playwright.config.ts (1 hunks)
  • playwright.config.ts (1 hunks)
🔇 Additional comments (4)
.gitignore (1)

39-39: LGTM!

The artifacts/ directory is correctly placed under the Node/Next.js section and aligns with the junit output configuration in playwright.config.ts.

playwright.config.ts (3)

13-13: Verify that fullyParallel: false is intentional.

Disabling parallel test execution will slow down your test suite significantly. While this might be necessary for tests with shared state or resource constraints, it's typically better to design tests to be independently executable.

Please confirm:

  1. Is this setting required for test stability in CI?
  2. Have you considered refactoring tests to support parallel execution?
  3. Are there specific tests that need to run serially (which could be handled with test.describe.serial() instead)?

If parallel execution is causing issues, consider:

  • Using Playwright's test.describe.serial() for specific test groups
  • Implementing proper test isolation with unique test data
  • Using Playwright's built-in fixtures for resource management

7-8: Good configuration choices.

The environment-based baseURL and centralized junitOutput path are well-designed for CI/CD flexibility.


10-22: Configuration structure looks solid.

The timeout values, test directory path, and reporter configuration are appropriate for CI environments. The trace: 'retain-on-failure' setting is particularly useful for debugging failed CI runs.

Comment on lines 1 to 3
import config from '../playwright.config';

export default defineConfig({
testDir: './tests/e2e',
timeout: 30_000,
expect: { timeout: 15_000 },
use: {
baseURL: process.env.BASE_URL || 'http://localhost:3000',
headless: true,
trace: 'retain-on-failure',
launchOptions: {
args: [
'--ignore-gpu-blocklist',
'--use-gl=swiftshader',
'--enable-webgl',
'--disable-gpu-sandbox',
'--disable-web-security', // allow wasm decoders to initialise in CI
],
},
},
});
export default config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Clean re-export pattern, but consider future override needs.

The re-export approach effectively shares configuration from the root, which is clean and DRY. However, this approach loses the ability to override or extend configuration at the frontend level.

If you anticipate needing frontend-specific overrides in the future, consider this alternative pattern:

import rootConfig from '../playwright.config';
import { defineConfig } from '@playwright/test';

export default defineConfig({
  ...rootConfig,
  // Future frontend-specific overrides can go here
});

This maintains the shared configuration while allowing future customization without breaking changes.

🤖 Prompt for AI Agents
In frontend/playwright.config.ts around lines 1 to 3, the file simply re-exports
the root config which prevents easily adding frontend-specific overrides later;
change the export to use defineConfig and spread the root config so you can add
or override fields in the future (import the root config, call defineConfig with
...rootConfig and put any frontend-specific options after the spread).

Comment on lines 4 to 5
const requireFromFrontend = createRequire(resolve(__dirname, 'frontend/package.json'));
const { defineConfig } = requireFromFrontend('@playwright/test') as typeof import('@playwright/test');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify dependency installation and consider fragility of dynamic imports.

The createRequire pattern to dynamically load @playwright/test from the frontend's node_modules is unusual and fragile. This approach can fail if:

  • @playwright/test is not installed in frontend/node_modules
  • The frontend/package.json path changes
  • There are version mismatches between root and frontend dependencies

Consider these alternatives:

  1. Install @playwright/test as a dev dependency at the root level
  2. Use a monorepo tool (like npm workspaces) to manage shared dependencies
  3. Add error handling to provide clear messages if the dynamic import fails

Run this script to verify the current setup:


🏁 Script executed:

#!/bin/bash
# Verify @playwright/test installation and potential issues

echo "=== Checking if @playwright/test exists in frontend ==="
if [ -d "frontend/node_modules/@playwright" ]; then
  echo "✓ @playwright/test found in frontend/node_modules"
  fd --type f package.json frontend/node_modules/@playwright/test --exec jq -r '.version' 
else
  echo "✗ @playwright/test NOT found in frontend/node_modules"
fi

echo ""
echo "=== Checking root package.json for @playwright/test ==="
if [ -f "package.json" ]; then
  cat package.json | jq -r '.devDependencies["@playwright/test"] // "Not found in root"'
else
  echo "No root package.json found"
fi

echo ""
echo "=== Testing if playwright.config.ts can be loaded ==="
node -e "import('./playwright.config.ts').then(() => console.log('✓ Config loads successfully')).catch(e => console.error('✗ Config failed to load:', e.message))"

Length of output: 369


Fix missing ‘@playwright/test’ installation and remove fragile dynamic import.

Runtime loading of playwright.config.ts fails (“Cannot find module '@playwright/test'”). Add “@playwright/test” as a devDependency at the repo root (or configure npm/yarn workspaces) and replace the createRequire pattern with a direct import.

🤖 Prompt for AI Agents
In playwright.config.ts around lines 4 to 5, the config uses a fragile
createRequire(resolve(...)) to load '@playwright/test' from the frontend package
and fails at runtime because '@playwright/test' is not installed at the repo
root; fix by adding '@playwright/test' as a devDependency at the repo root (or
configure workspaces to expose it) and replace the dynamic createRequire pattern
with a direct static import from '@playwright/test' at the top of the file,
removing the createRequire/resolve code paths.

Comment on lines 24 to 30
args: [
'--ignore-gpu-blocklist',
'--use-gl=swiftshader',
'--enable-webgl',
'--disable-gpu-sandbox',
'--disable-web-security',
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Security risk: Remove --disable-web-security flag.

The --disable-web-security flag disables Chrome's same-origin policy and other security features. This is a significant security risk because:

  • Tests could inadvertently access external resources or sensitive data
  • It masks real CORS issues that would occur in production
  • It creates a false sense of security in test environments

If you're encountering CORS issues, address them properly by:

  1. Configuring your test server to allow the necessary origins
  2. Using Playwright's built-in request interception/mocking features
  3. Setting up proper CORS headers in your development environment

Apply this diff to remove the unsafe flag:

     launchOptions: {
       args: [
         '--ignore-gpu-blocklist',
         '--use-gl=swiftshader',
         '--enable-webgl',
         '--disable-gpu-sandbox',
-        '--disable-web-security',
       ],
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args: [
'--ignore-gpu-blocklist',
'--use-gl=swiftshader',
'--enable-webgl',
'--disable-gpu-sandbox',
'--disable-web-security',
],
launchOptions: {
args: [
'--ignore-gpu-blocklist',
'--use-gl=swiftshader',
'--enable-webgl',
'--disable-gpu-sandbox',
],
},
🤖 Prompt for AI Agents
In playwright.config.ts around lines 24 to 30, remove the
'--disable-web-security' entry from the browser launch args to eliminate the
unsafe bypass of same-origin protections; update the args array to omit that
flag and, if needed, handle CORS in tests by configuring the test server's CORS
headers or using Playwright's request interception/mocking utilities instead.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (3)
playwright.config.ts (3)

4-5: Install @playwright/test at root and remove fragile dynamic import.

This dynamic require pattern is fragile and will fail if @playwright/test is not installed in frontend/node_modules. Past review already identified this critical issue with a clear fix: add @playwright/test as a devDependency at the repository root and replace the createRequire pattern with a standard static import.


10-12: Fix testDir path resolution for frontend re-export.

Past review correctly identified that when frontend/playwright.config.ts re-exports this config, the relative path 'frontend/tests/e2e' resolves from the frontend directory, resulting in frontend/frontend/tests/e2e. This breaks existing frontend test scripts.


29-29: Remove --disable-web-security flag.

Past review correctly identified that --disable-web-security disables Chrome's same-origin policy and creates significant security risks. This flag masks real CORS issues that should be addressed through proper test server configuration or Playwright's request interception features.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fce5765 and 930361b.

📒 Files selected for processing (1)
  • playwright.config.ts (1 hunks)
🔇 Additional comments (3)
playwright.config.ts (3)

7-8: LGTM!

The baseURL configuration with environment variable fallback and absolute path for JUnit output are both appropriate for CI environments.


15-18: LGTM!

The reporter configuration with list for console output and junit for CI integration aligns perfectly with the PR objective to configure Playwright reporting for CI environments.


19-22: LGTM!

The use options are well-configured for CI: headless mode for resource efficiency and trace retention on failure for debugging without excessive storage overhead.

export default defineConfig({
testDir: resolve(__dirname, 'frontend/tests/e2e'),
timeout: 60_000,
fullyParallel: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider enabling fullyParallel for CI performance.

Setting fullyParallel: false may slow down CI test runs. In CI environments, parallel test execution is typically preferred to reduce pipeline duration. Verify whether there's a specific reason to disable parallel execution (e.g., shared state, database constraints).

🤖 Prompt for AI Agents
In playwright.config.ts around line 13, fullyParallel is set to false which can
slow CI; update configuration to enable parallelism by setting fullyParallel:
true for CI runs (either change the value directly if no shared-state
constraints exist, or conditionally set fullyParallel = process.env.CI ? true :
false) and ensure any tests that rely on shared global state are made isolated
or marked as serial to avoid flakiness.

Comment on lines 25 to 28
'--ignore-gpu-blocklist',
'--use-gl=swiftshader',
'--enable-webgl',
'--disable-gpu-sandbox',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Document the purpose of GPU workaround flags.

The GPU-related flags (--ignore-gpu-blocklist, --use-gl=swiftshader, --enable-webgl, --disable-gpu-sandbox) are common workarounds for headless Chrome rendering issues in CI environments. Consider adding a comment explaining why these flags are necessary to help future maintainers understand their purpose.

🤖 Prompt for AI Agents
In playwright.config.ts around lines 25 to 28, the GPU-related Chromium flags
are listed without explanation; add a concise comment above or next to these
flags explaining they are CI/workaround flags to force software GL
(SwiftShader), enable WebGL, ignore GPU blacklists and disable the GPU sandbox
to avoid headless Chrome rendering failures in certain CI/container
environments, and mention any relevant platform/CI (e.g., Docker/GitHub Actions)
and link to an upstream doc/issue if available.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Caution

Docstrings generation - FAILED

No docstrings were generated.

@shayancoin shayancoin merged commit 97d0904 into main Oct 18, 2025
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant