Untestable Code and Coverage Exclusions

This document explains which parts of the Tetromino codebase are intentionally excluded from unit-test coverage targets and why.

Coverage Targets

Metric Global Threshold Rationale
Statements 70% Critical business logic is well covered; UI integration code is excluded
Branches 65% Branch-heavy UI code pulls down the average
Functions 40% Many Obsidian callback functions are not unit-testable
Lines 70% Same rationale as statements

Per-Module Targets (Documented, Not Enforced in CI)

The following modules contain critical business logic and are expected to maintain high coverage:

Module Statement Target Branch Target Function Target Line Target
src/api.ts 90% 75% 90% 90%
src/sync-engine.ts 80% 55% 85% 80%
src/utils.ts 95% 75% 100% 95%
src/templateUtils.ts 95% 85% 100% 95%
src/diff.ts 95% 85% 100% 95%
src/migration.ts 90% 70% 100% 90%
src/main.ts 80% 75% 55% 80%
src/securityUtils.ts 85% 50% 100% 85%
src/types.ts 100% 100% 100% 100%

Note: Per-file thresholds are not enforced in jest.config.cjs because Jest’s threshold matching for absolute paths is brittle across environments. Reviewers should manually verify the coverage report for critical modules.

Excluded / Low-Priority Modules

src/settings-tab.ts (~2% coverage)

Why excluded: This file contains the Obsidian PluginSettingTab implementation. It is pure UI construction code:

Testing strategy: Covered by manual testing in a real Obsidian vault.

src/modals.ts (~8% coverage)

Why excluded: This file contains Obsidian Modal subclasses:

These classes construct DOM elements inside Obsidian’s modal system. Their logic is mostly presentation (rendering stats, diffs, buttons). The underlying data (SyncResult, MigrationPlan) is thoroughly tested in sync-engine.test.ts and migration.test.ts.

Testing strategy: Manual verification in Obsidian.

Uncovered Lines in Otherwise Well-Covered Modules

src/api.ts

src/sync-engine.ts

src/utils.ts

src/securityUtils.ts

How to Read the Coverage Report

When reviewing a PR, focus on:

  1. Critical modules (api.ts, sync-engine.ts, utils.ts, templateUtils.ts, diff.ts, migration.ts) — ensure no significant drops.
  2. New code — every new feature should include tests.
  3. Branch coverage — statement coverage can be misleading; check that new branches are hit.

Ignore coverage changes in:

Running Coverage Locally

npm test -- --coverage

Or to see a specific file:

npx jest --coverage --collectCoverageFrom="src/api.ts"