Add comprehensive Jest unit tests with clean configuration and 25%+ code coverage#63
Conversation
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR establishes comprehensive Jest unit testing infrastructure for the Unthread Telegram Bot, implementing 71 test cases across 3 core utility modules to achieve approximately 29% code coverage with a focus on pure utility functions.
- Adds Jest 29.7.0 testing framework with TypeScript and ES modules support
- Implements comprehensive test suites for message parsing, input validation, and environment configuration utilities
- Establishes traditional
src/__tests__/directory structure with new npm test scripts
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/simpleValidators.test.ts | Tests input validation utilities with edge cases for ticket summary validation and text statistics |
| src/tests/messageContentExtractor.test.ts | Tests message parsing utilities covering text extraction, command detection, and message type analysis |
| src/tests/env.test.ts | Tests environment configuration utilities including variable access, environment detection, and configuration validation |
| package.json | Adds Jest dependencies and test scripts for running tests, watch mode, and coverage |
| TESTING.md | Documentation for the testing setup, coverage breakdown, and usage instructions |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot can you fix this? ● SimpleInputValidator › getStats › should handle single word |
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Fixed! The |
|
@copilot we are getting minimatch issues when using yarn test:coverage can you find a solution to that and also can we remove or hide these error when using yarn test? ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
}, |
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
... Fixed both issues:
Both |
This PR establishes a foundational Jest testing infrastructure for the Unthread Telegram Bot, implementing comprehensive unit tests that achieve approximately 29% code coverage across core utility functions.
What's Added
Testing Infrastructure
src/__tests__/directory structure as requestedtransformsyntax (no deprecation warnings)test,test:watch, andtest:coverageComprehensive Test Coverage (71 Tests)
Message Content Extraction (
messageContentExtractor.ts)Tests cover all core message parsing utilities that handle Telegram's diverse message types:
Input Validation (
simpleValidators.ts)Validates user input for ticket creation with comprehensive edge case testing:
Environment Configuration (
env.ts)Tests configuration utilities that manage bot setup and deployment:
Technical Improvements
globalstotransformsyntaxyarn testandyarn test:coveragerun without warnings or errorsTesting Strategy
The tests focus on pure utility functions with no external dependencies, making them:
Coverage Achievement
Documentation
Added
TESTING.mdwith:Quality Assurance
yarn buildThis establishes a solid, maintainable foundation for the project's testing infrastructure, focusing on the most critical utility functions that power the bot's core message processing and configuration management capabilities.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.