Add Vitest Testing Framework Setup with Comprehensive Configuration and Documentation #17
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.
Overview
This PR implements a complete Vitest testing framework for the unthread-webhook-server project, providing a fast, modern testing solution with first-class TypeScript support and comprehensive coverage reporting capabilities.
What's Changed
🧪 Testing Infrastructure
Vitest Installation
[email protected]as the core testing framework@vitest/[email protected]for interactive test debugging@vitest/[email protected]for V8-based coverage reportingTest Scripts (using yarn as per project standards)
Configuration
vitest.config.tswith:📝 Documentation
README.md
Added a comprehensive Testing section documenting:
TESTING.md (New)
Created extensive testing guide with:
CONTRIBUTING.md
Updated to reflect the new testing infrastructure:
🔧 VS Code Integration
.vscode/settings.jsonwith Vitest configuration.vscode/extensions.jsonto recommendvitest.explorerextension🚀 CI/CD Integration
Validate Workflow (
validate.yml)Build Workflow (
build.yml)📦 Configuration Updates
TypeScript
tsconfig.jsonto exclude test files from production buildGit
.gitignoreto exclude coverage artifacts and test results🧪 Example Test
Created
src/utils/signature.test.tsdemonstrating:Benefits
Verification
All commands tested and working:
yarn test- Runs tests successfullyyarn test:watch- Watch mode works correctlyyarn test:ui- Interactive UI launches properlyyarn test:coverage- Coverage reports generate in multiple formatsyarn type-check- TypeScript compilation passesyarn build- Production build succeeds without test filesCoverage Configuration
Next Steps
With this foundation in place, contributors can now:
This implementation provides a production-ready testing foundation that aligns with modern TypeScript development practices while maintaining compatibility with the project's existing tooling and workflows.
Original prompt
Add Vitest Testing Framework Setup
Vitest Testing Framework Setup
Objective
Implement Vitest as the testing framework for the unthread-webhook-server project, providing a fast, modern testing solution with TypeScript support and coverage reporting capabilities.
Core Requirements
1. Vitest Installation
Install Vitest and essential testing dependencies:
vitest- Core testing framework@vitest/ui- Optional interactive UI for test debugging@vitest/coverage-v8- Coverage reporting (V8 provider)@types/node- Already installed, ensure compatibility2. Package.json Scripts Configuration
Add the following test scripts using pnpm package manager:
Expected Behavior:
pnpm test→ Runs all tests once and exitspnpm test:watch→ Runs tests in watch mode (auto re-run on changes)pnpm test:ui→ Opens interactive test UI in browserpnpm test:coverage→ Generates coverage reports3. Vitest Configuration File
Create
vitest.config.tsat project root:4. Test Directory Structure
Create basic test structure (setup only, no actual tests yet):
OR use co-located tests:
Recommendation: Use co-located tests (
src/**/*.test.ts) for better maintainability.5. Example Test File
Create ONE simple example test to verify setup works:
File:
src/utils/signature.test.ts(or similar location)6. TypeScript Configuration Updates
Ensure
tsconfig.jsonincludes test files and Vitest types:{ "compilerOptions": { "types": ["node", "vitest/globals"] }, "include": ["src/**/*", "**/*.test.ts", "**/*.spec.ts"], "exclude": ["node_modules", "dist"] }7. Git Ignore Updates
Add coverage and test artifacts to
.gitignore:8. CI/CD Integration Preparation
Add placeholder for GitHub Actions workflow (or update existing):
9. Documentation Updates
Update README.md with Testing section:
Writing Tests
Tests are co-located with source files using the
.test.tssuffix:Coverage Requirements