Skip to content

feat: add vitest testing infrastructure#526

Open
ventilla wants to merge 1 commit intoobsidianmd:masterfrom
ventilla:feat/vitest-testing
Open

feat: add vitest testing infrastructure#526
ventilla wants to merge 1 commit intoobsidianmd:masterfrom
ventilla:feat/vitest-testing

Conversation

@ventilla
Copy link
Copy Markdown

@ventilla ventilla commented Apr 7, 2026

Summary

  • Adds vitest + @vitest/coverage-v8 as dev dependencies
  • 74 passing tests across 4 test files covering util, mime, template, and filesystem modules
  • __mocks__/obsidian.ts — mock for the obsidian runtime module so source files need zero test-specific changes
  • vitest.config.ts — standalone config (no coupling to esbuild build)
  • tests/fixtures/README.md — documents existing fixture directories and snapshot testing patterns
  • npm scripts: test, test:watch, test:coverage

How to extend

New importer tests go in tests/unit/formats/<name>.test.ts. The existing fixture files (bear, csv, evernote, html, journal, keep, notion, roam, textbundle, tomboy) can be used for snapshot tests. See tests/fixtures/README.md for patterns.

Test results

 Test Files  4 passed (4)
      Tests  74 passed (74)
   Duration  169ms

Design decisions

  • vitest over jest: native ESM + TypeScript, zero-config, faster. No conflict with esbuild.
  • Module alias for obsidian: resolve.alias in vitest config redirects obsidian imports to mock — no source changes needed.
  • Coverage scoped initially: excludes src/formats/** (heavy Obsidian API coupling). Format tests can be added incrementally as mocking improves.

🤖 Generated with Claude Code

Add vitest with 74 passing tests covering util, mime, template, and
filesystem modules. Includes obsidian module mock and fixture docs.

- vitest + @vitest/coverage-v8 as dev dependencies
- __mocks__/obsidian.ts for runtime module mocking
- tests/unit/ with 4 test files (util, mime, template, filesystem)
- tests/fixtures/README.md documenting snapshot testing patterns
- npm scripts: test, test:watch, test:coverage
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.

1 participant