Skip to content

feat: add comprehensive test suite with 100% coverage and Codecov integration#13

Merged
katieschilling merged 4 commits intomainfrom
katie/add-tests-code-cov
Jan 5, 2026
Merged

feat: add comprehensive test suite with 100% coverage and Codecov integration#13
katieschilling merged 4 commits intomainfrom
katie/add-tests-code-cov

Conversation

@katieschilling
Copy link
Copy Markdown
Contributor

Summary

  • Adds comprehensive test suite achieving 100% statement coverage with 348 tests
  • Integrates Codecov for continuous coverage tracking with GitHub Actions
  • Implements AWS MCP-inspired testing patterns for improved test infrastructure

Changes

Test Infrastructure

  • Added vitest.config.ts with coverage thresholds (95% statements, 85% branches, 90% functions, 95% lines)
  • Created src/test/setup.ts for global test configuration (log suppression, mock cleanup)
  • Added tsconfig.test.json for separate test file TypeScript configuration
  • Updated eslint.config.js to handle test files with relaxed rules

Test Helpers

  • src/test/helpers/express-mocks.ts - Mock Express request/response objects
  • src/test/helpers/mock-idp-client.ts - Mock OIDC client for testing
  • src/test/helpers/mock-store.ts - Mock Keyv store for testing
  • src/test/helpers/validation.ts - AWS MCP-inspired validation helpers
  • src/test/constants.ts - Shared test constants

Test Files Added

  • src/core/adapter.test.ts - KeyvAdapter tests
  • src/express/middleware.test.ts - Express middleware tests
  • src/mcp/auth-provider.test.ts - MCP auth provider with supertest integration tests
  • src/mcp/setup.test.ts - Setup function tests
  • src/oidc/client.test.ts - OIDC client tests
  • src/oidc/provider.test.ts - OIDC provider tests
  • src/oidc/server.test.ts - Server configuration tests
  • src/oidc/server.integration.test.ts - Server integration tests
  • src/utils/jwks.test.ts - JWKS generation tests
  • src/utils/logger.test.ts - Logger utility tests
  • src/utils/index.test.ts - Index exports tests

CI/CD

  • Added .github/workflows/codecov.yml for coverage reporting on PRs
  • Coverage reports uploaded to Codecov with CODECOV_TOKEN secret

Code Improvements

  • Standardized JWT decoding using jose library's decodeJwt
  • Added onVerifyError callback to McpAuthProviderOptions for debugging
  • Added comprehensive JSDoc documentation for token expiration utilities

Test Plan

  • Run npm test - All 348 tests pass
  • Run npm run test:coverage - Coverage thresholds met
  • Run npm run lint - No lint errors
  • Run npm run build - Build succeeds
  • Verify Codecov integration after merge

🤖 Generated with Claude Code

katieschilling and others added 2 commits December 18, 2025 15:01
…egration

- Add 348 tests across all modules with 100% statement coverage
- Add CI workflow with test, coverage, and Codecov upload
- Add vitest configuration with coverage thresholds (95% statements, 85% branches)
- Add shared test helpers: mock-store, mock-idp-client, express-mocks, validation
- Add test setup file with log suppression (inspired by AWS MCP patterns)
- Add tsconfig.test.json for test file type checking
- Update eslint config to handle test files separately
- Standardize JWT decoding using jose library across codebase
- Add onVerifyError callback for token verification debugging
- Add comprehensive JSDoc documentation for token refresh logic
- Refactor tests to check behavior instead of implementation details

Test infrastructure improvements:
- Test constants for eliminating magic strings
- Validation helpers for common assertion patterns
- Mock factories for Keyv stores and OIDC clients
- Express request/response mock builders

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The src/test/** directory contains test helpers that use looser typing
for mocking purposes. These files are covered by tsconfig.test.json for
eslint, but should be excluded from the main tsc --noEmit check.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@Xe Xe left a comment

Choose a reason for hiding this comment

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

The Griffin would approve of this code. Some things seem questionable (like testing the value of constants, i get it but whyyy), but it's fine enough.

- Remove config.test.ts - constants are already covered by usage in other tests
- Simplify index.test.ts to check exports exist rather than testing constant values
- Testing that `600 === 600` adds no value; export existence checks catch broken exports

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment on lines +74 to +82
expect(DEFAULT_ACCESS_TOKEN_TTL).toBeDefined();
expect(DEFAULT_AUTHORIZATION_CODE_TTL).toBeDefined();
expect(DEFAULT_ID_TOKEN_TTL).toBeDefined();
expect(DEFAULT_REFRESH_TOKEN_TTL).toBeDefined();
expect(DEFAULT_INTERACTION_SESSION_TTL_MS).toBeDefined();
expect(DEFAULT_USER_SESSION_TTL_MS).toBeDefined();
expect(DEFAULT_INTERACTION_TTL).toBeDefined();
expect(DEFAULT_GRANT_TTL).toBeDefined();
expect(DEFAULT_SESSION_TTL).toBeDefined();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My thought here is like: my brother in christ if the things weren't defined then the import statement at the top would fail.

As the reviewer noted: if the exports weren't defined, the import statement
would fail. The toBeDefined() checks add nothing. The src/index.ts barrel
file is now excluded from coverage since it's just re-exports with no logic.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@katieschilling katieschilling merged commit 0dbbb6d into main Jan 5, 2026
3 checks passed
@katieschilling katieschilling deleted the katie/add-tests-code-cov branch January 5, 2026 22:11
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 5, 2026

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

3 participants