Testing
Vitest suite, coverage targets, and how to run Chroma-Fs tests locally.
Chroma-Fs uses Vitest with fake-indexeddb for unit and integration tests. Filesystem tests mock the Tauri adapter so CI and local runs do not require a Tauri host.
Commands
From the Chroma-Fs directory:
npm install
npm run build
npm test # run once
npm run test:watch # watch mode
npm run test:coverage # coverage report (v8)
npm run typecheckTest layout
| Path | Scope |
|---|---|
test/path.test.ts | Path normalization helpers |
test/config.test.ts | Config parsing, platform detection, backend resolution |
test/indexeddb.test.ts | IndexedDB backend + shared storage contract |
test/filesystem.test.ts | Filesystem backend with mock Tauri adapter |
test/integration.test.ts | createStorage() config switching and fetch-based config |
test/helpers/storage-contract.ts | Shared CRUD contract exercised on both backends |
test/helpers/mock-tauri-adapter.ts | In-memory Tauri FS mock |
What is covered
- IndexedDB backend — read/write text and binary, mkdir, list, delete, rmdir (recursive), path normalization, error cases.
- Filesystem backend — same contract via injected
TauriFsAdaptermock (no real@tauri-apps/plugin-fsin tests). - Unified API —
runStorageContract()runs identical assertions against both backends. - Configuration — inline config,
configPath+fetch, platform defaults (static → IndexedDB, desktop → filesystem).
Coverage notes
Coverage is reported for src/**/*.ts. Bridge (post-message-adapter) and default Tauri wrapper paths are exercised in desktop integration, not in unit tests. Target for core backends and config is >85% line coverage on src/backends/ and src/config.ts.
Dev mode verification (ecosystem)
Dynamic template projects with "dev": { "desktop": true } in chroma.json trigger chroma dev to:
- Start the engine dev server on the configured port.
- Launch Chroma Desktop with
--develop --url http://127.0.0.1:<port>/<entry> --title <name>.
Chroma Desktop reads develop mode from CLI args or get_develop_mode, hides the library menu, and loads the project URL directly. Use chroma dev --no-desktop to skip the desktop shell.
Related
- Configuration —
chroma-fs.jsonper template - CLI dev mode —
chroma devand--no-desktop