Test Coverage Gap Analysis — micr-dev/blog
Executive Summary
| Metric |
Value |
| Source files (non-test, non-type-decl) |
61 files (~4,554 LOC) |
| Test files |
3 files (212 LOC) |
| Tests |
12 passing |
| Test framework |
Vitest 4.1 (node environment) |
| Test-to-code ratio |
~4.7% by LOC |
| Modules with any test coverage |
5 of 61 files (~8%) |
| Estimated functional coverage |
~15-20% of pure-logic code |
Files WITH Tests
| Source File |
Test File |
What's Tested |
src/lib/post-parser.ts |
src/lib/posts.test.ts |
parseEditablePost, default merging, frontmatter parsing |
src/lib/posts.ts |
src/lib/posts.test.ts |
slugifyTag |
src/lib/mdx.tsx |
src/lib/mdx.test.ts |
renderMdx (shortcodes, mermaid fallback, ascii fences), getFontStyleSheet, getThemeStyle |
src/lib/mermaid-ascii.ts |
src/lib/mdx.test.ts |
renderMermaidAscii (flowcharts, sequences) |
src/lib/share-links.ts |
src/lib/share-links.test.ts |
buildShareHref (x, bluesky, linkedin) |
Files WITHOUT Tests
54 source files have zero test coverage, including all React components, all route pages, the API proxy, and several utility modules.
Critical Test Gaps
P0 — High Severity
1. src/lib/post-parser.ts — Zod validation edge cases
- Gap: Only happy-path parsing tested. No tests for missing frontmatter, invalid YAML, malformed dates, empty required fields.
- Recommended tests: Missing
--- delimiters, invalid YAML, empty title/date/excerpt, non-date strings for date, missing optional fields.
- Effort: 2–3 hours
2. src/lib/posts.ts — Post loading, tag aggregation, adjacent posts
- Gap: Only
slugifyTag tested. Critical functions untested: getPostBySlug, getPostIndex, getTags, getPostsByTag, getAdjacentPosts, formatDate.
- Recommended tests:
formatDate() edge cases, getAdjacentPosts() first/last/empty, getTags() dedup/count, getPostBySlug() null returns.
- Effort: 3–4 hours
3. src/lib/mermaid-ascii.ts — Parser edge cases
- Gap: Only simple flowchart/sequence tested. Complex regex logic with many untested branches.
- Recommended tests: Empty input, edge labels, different arrow types, node shapes, unknown diagram types, malformed lines.
- Effort: 2–3 hours
P1 — Medium-High Severity
4. src/lib/mdx.tsx — MDX component rendering edge cases
- Gap: Happy paths only. Many
getMdxComponents branches untested.
- Effort: 3–4 hours
5. src/lib/og.tsx — OG image layout calculations
- Gap: Pure functions
getOgTitleStyle, getScytheFrame, getOgPreviewTheme completely untested.
- Effort: 1–2 hours
6. src/lib/og-assets.ts — SVG manipulation
- Gap:
tintSvg, cropScytheSvg, svgToDataUri are pure functions that could be tested.
- Effort: 1 hour
P2 — Medium Severity
7. src/components/search-page.tsx (169 LOC) — Search functionality
- Gap: Largest component with zero tests. Extract search/filter logic into pure utility for testing.
- Effort: 2–3 hours
8. src/components/local-editor.tsx (305 LOC) — MDX editor
- Gap: Largest file, completely untested. Contains file-system access and editor state management.
- Effort: 3–4 hours
9. src/app/sitemap.ts — Sitemap generation
- Gap: No tests verify correct URL structure.
- Effort: 1 hour
10. src/app/api/agentation/[...path]/route.ts — API proxy
- Gap: Request forwarding, header stripping, dev-only guard untested.
- Effort: 1–2 hours
Recommendations
Immediate Actions
- Add coverage reporting — Add
"test:coverage": "vitest run --coverage" and install @vitest/coverage-v8.
- Expand
post-parser.ts tests — Zod schema validation is the most critical safety net. Malformed frontmatter could crash the blog.
- Test
posts.ts functions — Mock filesystem and test all exported functions.
- Expand
mermaid-ascii.ts tests — Many regex patterns need edge case coverage.
Configuration Improvements
- Enable
*.test.tsx — vitest config include should be ["src/**/*.test.{ts,tsx}"].
- Add
jsdom environment for component tests — @testing-library/react requires DOM.
Generated by Nightshift v3 (GLM 5.1)
Test Coverage Gap Analysis — micr-dev/blog
Executive Summary
Files WITH Tests
src/lib/post-parser.tssrc/lib/posts.test.tsparseEditablePost, default merging, frontmatter parsingsrc/lib/posts.tssrc/lib/posts.test.tsslugifyTagsrc/lib/mdx.tsxsrc/lib/mdx.test.tsrenderMdx(shortcodes, mermaid fallback, ascii fences),getFontStyleSheet,getThemeStylesrc/lib/mermaid-ascii.tssrc/lib/mdx.test.tsrenderMermaidAscii(flowcharts, sequences)src/lib/share-links.tssrc/lib/share-links.test.tsbuildShareHref(x, bluesky, linkedin)Files WITHOUT Tests
54 source files have zero test coverage, including all React components, all route pages, the API proxy, and several utility modules.
Critical Test Gaps
P0 — High Severity
1.
src/lib/post-parser.ts— Zod validation edge cases---delimiters, invalid YAML, empty title/date/excerpt, non-date strings fordate, missing optional fields.2.
src/lib/posts.ts— Post loading, tag aggregation, adjacent postsslugifyTagtested. Critical functions untested:getPostBySlug,getPostIndex,getTags,getPostsByTag,getAdjacentPosts,formatDate.formatDate()edge cases,getAdjacentPosts()first/last/empty,getTags()dedup/count,getPostBySlug()null returns.3.
src/lib/mermaid-ascii.ts— Parser edge casesP1 — Medium-High Severity
4.
src/lib/mdx.tsx— MDX component rendering edge casesgetMdxComponentsbranches untested.5.
src/lib/og.tsx— OG image layout calculationsgetOgTitleStyle,getScytheFrame,getOgPreviewThemecompletely untested.6.
src/lib/og-assets.ts— SVG manipulationtintSvg,cropScytheSvg,svgToDataUriare pure functions that could be tested.P2 — Medium Severity
7.
src/components/search-page.tsx(169 LOC) — Search functionality8.
src/components/local-editor.tsx(305 LOC) — MDX editor9.
src/app/sitemap.ts— Sitemap generation10.
src/app/api/agentation/[...path]/route.ts— API proxyRecommendations
Immediate Actions
"test:coverage": "vitest run --coverage"and install@vitest/coverage-v8.post-parser.tstests — Zod schema validation is the most critical safety net. Malformed frontmatter could crash the blog.posts.tsfunctions — Mock filesystem and test all exported functions.mermaid-ascii.tstests — Many regex patterns need edge case coverage.Configuration Improvements
*.test.tsx— vitest configincludeshould be["src/**/*.test.{ts,tsx}"].jsdomenvironment for component tests —@testing-library/reactrequires DOM.Generated by Nightshift v3 (GLM 5.1)