Skip to content

Testing

Framework

DeLive uses Vitest for frontend testing with the following configuration:

  • Environment: node (not jsdom — no DOM APIs in tests)
  • Globals: true (no need to import describe, it, expect)
  • Include pattern: src/**/*.test.ts
  • Alias: @frontend/src

Running Tests

bash
npm run test:frontend

Or from the frontend directory:

bash
cd frontend && npx vitest run

For watch mode during development:

bash
cd frontend && npx vitest

Test Coverage

Current suite: ~200 tests across 23 files.

What's Tested

AreaFilesCoverage
Session schema & normalizationsessionSchema.test.tsSchema upgrades, field normalization
Session metadatasessionMetadata.test.tsTitle generation, time formatting
Session lifecyclesessionLifecycle.test.tsDraft creation, source meta
Session repositorysessionRepository.test.tsCache operations, persistence
Session snapshotsessionSnapshot.test.tsContent detection, snapshot building
Transcript stabilizertranscriptStabilizer.test.tsStable prefix detection
Windowed transcriptwindowedTranscript.test.tsOverlap handling, text merging
Transcript statetranscriptState.test.tsEvent application
Storage utilitiesstorage.test.ts, backupStorage.test.tsID generation, backup normalization
Provider configproviderConfig.test.tsConfig building, validation
Provider base classproviders/__tests__/base.test.tsState machine, event emitter
Windowed batch providerproviders/__tests__/windowedBatch.test.tsRolling buffer, scheduling, stabilization
ASR typestypes/asr/common.test.tsType guards, capability checks
Subtitle exportsubtitleExport.test.tsSRT/VTT generation
Caption line wrapcaptionLineWrap.test.tsText wrapping logic
AI post-processaiPostProcess.test.tsResponse parsing
Rolling bufferrollingAudioBuffer.test.tsBuffer management
API IPC responderuseApiIpcResponder.test.tsData transformation

What's Not Tested

  • React components — no .test.tsx files (node environment, no jsdom)
  • Electron main process — not under Vitest
  • MCP server — separate package, not in CI
  • Integration tests — no end-to-end API testing

Writing Tests

Tests follow the pattern:

typescript
import { describe, it, expect } from 'vitest'
import { yourFunction } from '../yourModule'

describe('yourFunction', () => {
  it('should handle normal case', () => {
    expect(yourFunction('input')).toBe('expected')
  })

  it('should handle edge case', () => {
    expect(yourFunction('')).toBeNull()
  })
})

CI Integration

Tests run as part of npm run check in both the CI pipeline (on push/PR) and the release pipeline (before building).

Released under the Apache 2.0 License.