Skip to content

test(core): add Vitest setup and unit tests - #1

Merged
runtimebug merged 3 commits into
mainfrom
feat/vitest-setup
Feb 8, 2026
Merged

test(core): add Vitest setup and unit tests#1
runtimebug merged 3 commits into
mainfrom
feat/vitest-setup

Conversation

@runtimebug

Copy link
Copy Markdown
Owner

Summary

Implements Task 2 of Phase 1 from the Evolution Plan: Vitest setup + unit tests for parseUnifiedDiff, config loading, and response parsing.

Changes

  • Install Vitest and @vitest/coverage-v8 for testing
  • Create vitest.config.ts with coverage settings
  • Add 15 tests for parseUnifiedDiff.ts
  • Add 26 tests for config/index.ts
  • Add 20 tests for OpenAI response parsing
  • Add test fixtures for diffs, configs, and responses
  • Add GitHub Actions CI workflow for automated testing
  • Update package.json with test scripts
  • Update .gitignore to exclude coverage/

Test Coverage

  • parseUnifiedDiff: 15 tests covering basic functionality, line number annotation, multiple hunks, context lines, and edge cases
  • config loading: 26 tests covering config file discovery, CLI merging, validation, and error handling
  • response parsing: 20 tests covering summary/inline styles, various separators, file paths, and edge cases

Total: 61 unit tests

How to Test

npm install
npm test          # Run tests once
npm run test:watch    # Run tests in watch mode
npm run test:coverage # Run tests with coverage

Checklist

  • Code compiles: npm run build
  • All tests pass: npm test
  • PR title follows Angular commit convention
  • No secrets or API keys included

…fig, and response parsing

- Install Vitest and @vitest/coverage-v8 for testing
- Create vitest.config.ts with coverage settings
- Add 15 tests for parseUnifiedDiff covering:
  - Basic functionality (empty input, no patch, deleted files)
  - Line number annotation for added lines
  - Multiple hunks handling
  - Context lines and deleted lines
  - Hunk header parsing
  - Edge cases (special chars, empty lines, metadata)

- Add 26 tests for config loading covering:
  - Config file discovery (JSON and YAML)
  - CLI options merging and precedence
  - Provider, platform, and severity validation
  - Error handling for invalid configs

- Add 20 tests for OpenAI response parsing covering:
  - Summary style comments
  - Inline comment parsing with various separators
  - File path handling with special characters
  - Edge cases (empty content, high line numbers)
  - Constructor validation

- Add test fixtures for diffs, configs, and responses
- Add GitHub Actions CI workflow for automated testing
- Update package.json with test scripts
- Update .gitignore to exclude coverage/

Part of Phase 1, Task 2 from Evolution Plan
- Add .eslintrc.json configuration file
- Fix changeset-lint.yml to fetch full git history
- Fix lint errors in test files (unused imports, prefer-const)
- Fix TypeScript type issues in config tests
- Rename vitest.config.ts to vitest.config.mts for ESM support
- Update test scripts to use new config filename
- Add empty changeset for test infrastructure changes
@runtimebug
runtimebug merged commit 1a63037 into main Feb 8, 2026
3 checks passed
@runtimebug
runtimebug deleted the feat/vitest-setup branch February 8, 2026 16:12
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.

1 participant