Skip to content

Add TypeScript unit tests and Cobertura coverage reporting with CI upload - #172

Open
remyleone with code-coverage-agent[bot] wants to merge 2 commits into
mainfrom
code-coverage-agent/setup-code-coverage-reporting
Open

Add TypeScript unit tests and Cobertura coverage reporting with CI upload#172
remyleone with code-coverage-agent[bot] wants to merge 2 commits into
mainfrom
code-coverage-agent/setup-code-coverage-reporting

Conversation

@code-coverage-agent

@code-coverage-agent code-coverage-agent AI commented Aug 5, 2026

Copy link
Copy Markdown

No test infrastructure existed; coverage reporting was impossible. This adds vitest-based unit tests and integrates Cobertura XML coverage into the CI pipeline.

Coverage configuration

  • vitest.config.ts — V8 provider, Cobertura reporter output to coverage/ (gitignored)
  • package.jsontestvitest run, test:coveragevitest run --coverage

Unit tests (src/__tests__/)

  • version.test.tsVERSION_LATEST constant
  • input.test.tsvalidateArgs with latest, explicit semver, and invalid version strings
  • config.test.tsexportConfig env var exports and importConfig env var reads
  • run.test.tsCLIError shape, non-zero exit → CLIError, shell-operator injection → Error
  • cli.test.tsfillEnv sets/skips env vars based on arg presence

CI integration (.github/workflows/test.yml)

Augmented the existing lint job — tests already share the install/build steps:

- run: pnpm test:coverage
  shell: bash
- name: Upload coverage artifact
  if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
  uses: actions/upload-artifact@v7
  with:
    name: coverage-report-typescript
    path: coverage/cobertura-coverage.xml

New upload-coverage-typescript job (elevated code-quality: write, fork-gated) downloads the artifact and calls actions/upload-code-coverage@v1.

ESLint

Added a test-file override in .eslintrc disabling import/first, import/order, and @typescript-eslint/require-await — required for vitest's vi.mock() hoisting pattern.

Co-authored-by: remyleone <300834+remyleone@users.noreply.github.com>
@code-coverage-agent code-coverage-agent AI changed the title [WIP] Set up code coverage reporting in CI workflows Add TypeScript unit tests and Cobertura coverage reporting with CI upload Aug 5, 2026
@code-coverage-agent
code-coverage-agent AI marked this pull request as ready for review August 5, 2026 16:33
Code Coverage Agent finished work on behalf of remyleone August 5, 2026 16:33
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