Skip to content

Set up proper test suite with Jest#11

Merged
GhostTypes merged 6 commits into
mainfrom
claude/setup-jest-tests-01EJ1yKTQdZCatuwzxFRvs1V
Nov 21, 2025
Merged

Set up proper test suite with Jest#11
GhostTypes merged 6 commits into
mainfrom
claude/setup-jest-tests-01EJ1yKTQdZCatuwzxFRvs1V

Conversation

@GhostTypes

Copy link
Copy Markdown
Owner

No description provided.

- Removed legacy src/test.ts manual integration test
- Configured Jest with ts-jest for TypeScript support
- Added test:coverage npm script with coverage thresholds
- Excluded coverage directory from git

Test Coverage (157 tests passing):
- NetworkUtils: 100% coverage
- Temperature utility: 100% coverage
- ScientificNotationFloatConverter: 100% coverage
- All TCP replay parsers: 93-100% coverage
  - PrinterInfo (M115 response parsing)
  - TempInfo (M105 response parsing)
  - PrintStatus (M27 response parsing)
  - EndstopStatus (M119 response parsing)
  - LocationInfo (M114 response parsing)
  - ThumbnailInfo (M662 PNG data parsing)
- Filament class: 100% coverage
- Info control module: Complete API test coverage
- Files control module: Existing test coverage maintained

Overall coverage: 32% (branches: 44%, functions: 24%, lines: 33%)
Coverage thresholds: 30% statements, 30% lines, 20% functions, 40% branches

All tests passing. Foundation set for continued test expansion.
Added 64 new tests for printer control API modules, achieving "easy wins"
coverage improvements as planned.

Test Coverage (221 tests passing, +64 from previous 157):

Control Module Coverage (src/api/controls):
- Control.ts: 93% statements, 95% branches, 100% functions
  - Tests for homing, filtration, camera, LED, fans, speed/offset
  - Tests for filament operations and runout sensor
  - Comprehensive sendControlCommand testing

- TempControl.ts: 100% coverage across all metrics
  - Tests for extruder and bed temperature control
  - Tests for temperature cancellation
  - Tests for part cooling wait functionality

- JobControl.ts: 46% statements, 52% branches, 79% functions
  - Tests for pause/resume/cancel operations
  - Tests for AD5X multi-color and single-color jobs
  - Comprehensive material mapping validation tests
  - Tests for printLocalFile with firmware version logic

- Info.ts: 96% statements, 96% branches, 100% functions
- Files.ts: 63% (maintained existing coverage)

Overall api/controls module: 63% statements, 70% branches, 91% functions

Project-wide coverage improvement:
- Overall: 32% → 44% (+12%)
- Branches: 44% → 52% (+8%)
- Functions: 24% → 42% (+18%)
- Lines: 33% → 45% (+12%)

All tests passing. Strong foundation for continued development.
Added comprehensive CI workflow that:
- Runs automatically on pull requests to main/master
- Can be manually triggered from Actions tab
- Tests against Node.js 18.x and 20.x for compatibility
- Runs full test suite with coverage reporting
- Enforces coverage thresholds (30% statements, 20% functions)
- Uploads coverage artifacts for review
- Displays coverage summary in workflow output

Workflow triggers on changes to:
- Source files (src/**)
- Package configuration (package.json, tsconfig.json)
- Workflow file itself

Features:
- Uses npm ci for reproducible builds
- Caches node_modules for faster runs
- Matrix strategy for multi-version testing
- Coverage report artifact retention (7 days)
- Clear pass/fail status reporting

This ensures all future PRs are automatically validated for quality.
@GhostTypes GhostTypes self-assigned this Nov 21, 2025
Changed workflow to:
- Pass CI when all tests pass (not dependent on coverage thresholds)
- Generate coverage report for informational purposes only
- Upload coverage artifact even if thresholds not met
- Display coverage summary but don't fail build on it

This ensures PRs can be merged when tests pass, while still providing
coverage visibility for code quality monitoring.
Removed coverage report generation and artifacts to focus on test validation.
Coverage can still be run locally with 'npm run test:coverage'.
@GhostTypes GhostTypes merged commit dce6cc0 into main Nov 21, 2025
1 check passed
@GhostTypes GhostTypes deleted the claude/setup-jest-tests-01EJ1yKTQdZCatuwzxFRvs1V branch November 21, 2025 23:36
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.

2 participants