Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@timfee
Copy link
Owner

@timfee timfee commented Jul 30, 2025

Fix CircleCI JUnit XML test result collection

Summary

Resolves the CircleCI "0 test results uploaded" issue by fixing JUnit XML generation problems in both unit and E2E test configurations. The root causes were:

  1. Missing script reference: playwright.config.test.ts referenced npm run serve which doesn't exist in package.json (should be npm start)
  2. File conflicts: Both Karma unit tests and Playwright E2E tests were writing to the same test-results/junit.xml file
  3. Configuration gaps: Missing karma-junit-reporter dependency and incomplete CircleCI browser orb usage

Key Changes:

  • Fixed Playwright webServer command to use existing npm start script
  • Separated JUnit XML outputs: junit.xml (unit tests) and e2e-junit.xml (E2E tests)
  • Added karma-junit-reporter dependency and configured Karma to output JUnit XML
  • Updated CircleCI to use Node.js v20.19 and proper browser-tools orb usage

Review & Testing Checklist for Human

  • Verify CircleCI shows test results uploaded instead of "0 test results uploaded" message
  • Test npm start command works correctly and serves the app on localhost:4200
  • Check CI logs to confirm both test-results/junit.xml and test-results/e2e-junit.xml files are generated
  • Run unit tests locally with npm run test:unit and verify test-results/junit.xml is created (should be ~75KB)
  • Test E2E configuration with npx playwright test --config=playwright.config.test.ts --list to confirm no script errors

Recommended Test Plan: Run the CircleCI pipeline and check the "Test Summary" tab to verify test results are properly uploaded and displayed, rather than showing "0 test results uploaded".


Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    subgraph "Test Configuration Files"
        A["playwright.config.test.ts"]:::major-edit
        B["karma.conf.js"]:::minor-edit
        C["package.json"]:::minor-edit
    end
    
    subgraph "CircleCI Pipeline"
        D[".circleci/config.yml"]:::context
        E["unit-tests job"]:::context
        F["e2e-tests job"]:::context
    end
    
    subgraph "Test Results"
        G["test-results/junit.xml<br/>(Unit Tests)"]:::context
        H["test-results/e2e-junit.xml<br/>(E2E Tests)"]:::context
    end
    
    A -->|"webServer: npm start"| E
    A -->|"junit reporter"| H
    B -->|"junit reporter"| G
    C -->|"karma-junit-reporter"| B
    E -->|"store_test_results"| G
    F -->|"store_test_results"| H
    D -->|"configures"| E
    D -->|"configures"| F
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit
        L3["Context/No Edit"]:::context
    end

classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
Loading

Notes

Local Testing Results:

  • Unit tests successfully generate junit.xml (75KB file confirmed)
  • Playwright configuration now lists tests without script errors
  • E2E tests still fail due to authentication setup, but script reference issue is resolved

Potential Risks:

  • E2E tests may not generate JUnit XML in CI if authentication issues persist
  • CircleCI environment may have different file generation timing than local testing

This PR was created with assistance from Devin AI
Link to Devin run: https://app.devin.ai/sessions/bd2b3c122e124b5c8c33c70100252188
Requested by: @timfee

- Fix playwright.config.test.ts to use 'npm start' instead of missing 'serve' script
- Separate E2E JUnit XML output to e2e-junit.xml to avoid conflicts with unit tests
- Ensure CircleCI store_test_results can collect both junit.xml and e2e-junit.xml

This addresses the CircleCI '0 test results uploaded' issue by:
1. Fixing the missing script reference that prevented E2E tests from running
2. Preventing file conflicts between unit and E2E test JUnit XML outputs
3. Maintaining separate test result files for better CI reporting

Co-Authored-By: Tim Feeley <[email protected]>
Copilot AI review requested due to automatic review settings July 30, 2025 07:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes CircleCI test result collection by resolving JUnit XML generation issues that were preventing test results from being uploaded. The main issue was a missing script reference and file conflicts between unit and E2E test outputs.

Key changes:

  • Fixed Playwright webServer command to use existing npm start instead of non-existent npm run serve
  • Separated JUnit XML outputs to prevent file conflicts between unit and E2E tests
  • Updated E2E test JUnit output filename to e2e-junit.xml


webServer: {
command: 'npm run serve -- --configuration=test',
command: 'npm start',
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The npm start command may not be suitable for test environments. Consider using a test-specific configuration like 'npm start -- --configuration=test' to ensure proper test environment setup with appropriate base URLs and environment variables.

Copilot generated this review using guidance from repository custom instructions.
devin-ai-integration bot and others added 2 commits July 30, 2025 07:39
… test failures

- Create test-results directory before running tests in CircleCI
- Configure karma-junit-reporter to always generate output files
- Handle test failures gracefully while preserving result collection
- Ensure coverage upload runs even when tests fail
- Add suite name to karma-junit-reporter for better organization

Co-Authored-By: Tim Feeley <[email protected]>
- Conditionally load karma-puppeteer-launcher only when not in CI
- Enhanced ChromeHeadlessCI launcher flags for better stability
- Resolves 'Cannot start ChromeHeadless' error in CircleCI
- Fixes JUnit XML generation by ensuring tests can run successfully

Co-Authored-By: Tim Feeley <[email protected]>
@timfee timfee merged commit 280b793 into main Jul 30, 2025
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants