-
Notifications
You must be signed in to change notification settings - Fork 2
🧪 Improve Test Coverage and Code Quality #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
isahohieku
wants to merge
12
commits into
corbado:main
Choose a base branch
from
isahohieku:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… handling - Add new assertion helper utility (src/helpers/assert.ts) - Enhance base error class with additional functionality - Improve configuration handling with better validation - Add comprehensive unit test suite: - Assert utility tests (tests/unit/assert.test.ts) - Configuration edge case tests (tests/unit/config-edge-cases.test.ts) - Error handling tests (tests/unit/errors.test.ts) - SDK error handling tests (tests/unit/sdk-error-handling.test.ts) - Services coverage tests (tests/unit/services-coverage.test.ts) - Utility function tests (tests/unit/utils.test.ts) - Update Jest setup configuration for better test environment - Update integration tests for user services This commit significantly improves code quality and test coverage across the SDK.
- Add collectCoverageFrom configuration to Jest - Exclude src/generated/**/*.ts (auto-generated API files) - Exclude src/**/*.d.ts (TypeScript declaration files) - Improves coverage accuracy by focusing on hand-written code - Overall coverage jumps from 41% to 72% for actual business logic
- Add UserService tests covering create, delete, get operations - Add IdentifierService tests covering create, delete, update operations - Add SDK core functionality tests for initialization and configuration - Include error handling, validation, and network error scenarios - Achieves 96%+ coverage on service layer - All tests use proper mocking with axios-mock-adapter
- Add tests for AxiosError with server error response parsing - Add tests for AxiosError with generic response handling - Add tests for AxiosError without response (network errors) - Improve convertToServerError function coverage from 71% to 98% - Add proper AxiosError instance creation for realistic testing - Achieves 98%+ statement coverage on helpers module
- Update isNotEmpty validation to check for undefined values - Ensures proper validation for null, undefined, and empty string cases - Improves robustness of input validation throughout the SDK
- Add tests for setSessionTokenCookieName method - Add tests for deprecated setShortSessionCookieName method - Add tests for setHttpClient custom client configuration - Add validation tests for empty cookie names - Improve code formatting consistency - Achieves 100% coverage on configuration module
- Add tests for notNull validation method - Add tests for notEmptyString validation method - Add tests for stringInSet validation with valid/invalid values - Add tests for keysInObject validation with missing keys - Add tests for validURL validation with various URL formats - Covers edge cases including credentials, paths, queries, fragments - Achieves 100% function coverage on assert helper
- Add complete BaseError tests with all constructor parameters - Add ValidationError tests with enum names and default values - Add ServerError tests with response data and getter methods - Add tests for validation message formatting and edge cases - Add tests for missing requestData and requestID handling - Achieves 100% coverage on all error classes - Covers inheritance chain validation (Error -> BaseError -> specific errors)
- Add collectCoverageFrom configuration to Jest - Exclude src/generated/**/*.ts (auto-generated API files) - Exclude src/**/*.d.ts (TypeScript declaration files) - Improves coverage accuracy by focusing on hand-written code - Overall coverage increases from 41% to 72% for actual business logic
- Move JOSEAlgNotAllowed import to proper location - Format multi-line conditional for better readability - Maintain consistent import ordering - No functional changes, only code style improvements
- Remove unnecessary async/await in JWT generation - Use object property shorthand (alg instead of alg: alg) - Improve multi-line function call formatting - Format long JWT strings for better readability - Consistent spacing and indentation throughout - No functional changes, only code style improvements
- Change relative imports to use .js extensions for ES modules - Update imports for src/index.js, src/errors/index.js, src/generated/index.js - Ensures compatibility with ES module resolution - Maintains consistency with other test files
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📄 Summary
This PR significantly improves test coverage accuracy and adds comprehensive unit tests for core SDK functionality. The overall statement coverage for hand-written code increases from 41% to 76%, with several modules achieving near-perfect coverage.
🔑 Key Changes
🎯 Test Coverage Improvements
collectCoverageFrom
configuration to Jest to excludesrc/generated/**/*.ts
and declaration files.AxiosError
handling tests (from 71% → 98% statement coverage).BaseError
,ServerError
, andValidationError
classes.📊 Coverage Results
🔧 Code Quality Improvements
.js
extensions.⚙️ Technical Details
Jest Configuration Updates
✅ New Test Coverage Areas
🚀 Benefits
📂 Files Changed
jest.config.js
– Coverage configurationsrc/services/sessionService.ts
– Code formatting improvementstests/unit/session.test.ts
– Formatting and readability improvementstests/utils.ts
– ES module import fixestests/unit/helpers.test.ts
– Enhanced AxiosError coverage (previous commits)tests/unit/identifier-service.test.ts
– Additional error handling tests (previous commits)🧪 Testing
🔜 Next Steps