Add frontend unit tests with Vitest + jsdom
- Create tests/frontend/utils/format.test.js with 24 tests for formatting utilities - Create tests/frontend/ui/downloads.test.js with 10 tests for DOM rendering functions - Update vitest.config.js to support jsdom environment for frontend tests - All 34 tests pass and cover edge cases (null, zero, large numbers, DOM structure)
This commit is contained in:
+8
-2
@@ -3,8 +3,6 @@ import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
// Node environment for all tests (server-side CJS modules, no browser APIs needed)
|
||||
environment: 'node',
|
||||
// Global test helpers (describe, it, expect, vi) without per-file imports
|
||||
globals: true,
|
||||
// Run each test file in an isolated module registry so module-level state
|
||||
@@ -12,6 +10,14 @@ export default defineConfig({
|
||||
isolate: true,
|
||||
// Give each file its own data directory so tokenStore file I/O doesn't collide
|
||||
setupFiles: ['./tests/setup.js'],
|
||||
// Environment configuration based on test type
|
||||
environmentMatchGlobs: [
|
||||
// Server tests use node environment (must come first - more specific)
|
||||
['tests/unit/**/*.js', 'node'],
|
||||
['tests/integration/**/*.js', 'node'],
|
||||
// Frontend tests need jsdom for DOM APIs (broader pattern comes last)
|
||||
['tests/frontend/**/*.js', 'jsdom']
|
||||
],
|
||||
// Coverage via V8 (built into Node — no babel transform needed)
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
|
||||
Reference in New Issue
Block a user