test: add unit-test harness (tsx + node:test) + first suite for utils/common
Addresses the "no automated test suite" gap. Chose Node's built-in test runner via tsx rather than vitest: the project is on Vite 8.0.14, ahead of vitest's supported Vite range, so vitest would fight peer deps. tsx is build-independent. - `npm test` → `node --import tsx --test $(find src -name '*.test.ts')` (works on Node 20 local + 24 CI without relying on --test glob support). - src/app/utils/common.test.ts: 15 tests covering the pure helpers (bytesToSize, time formatters, binarySearch, parseGeoUri, slash trimmers, nameInitials, randomStr, suffixRename, splitWithSpace, promise-settled helpers, etc.) — asserts actual behavior, traced from source. - common.ts: folds import made `import type` (it's types only) so the module is pure and testable without loading folds/CSS. - tsconfig excludes *.test.ts (tsx transpiles tests; eslint isn't type-aware so it still lints them); added an informational CI "Unit tests" step (promote to a hard gate by dropping continue-on-error). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,13 @@ jobs:
|
||||
VITE_APP_VERSION: ${{ github.sha }}
|
||||
|
||||
# ── Quality checks (informational — pre-existing issues exist) ───────
|
||||
# Unit tests run on Node's built-in runner via tsx (no vitest — Vite 8 is
|
||||
# ahead of vitest's supported range). Informational for now to match the
|
||||
# section's convention; promote to a hard gate by dropping continue-on-error.
|
||||
- name: Unit tests
|
||||
run: npm test
|
||||
continue-on-error: true
|
||||
|
||||
- name: TypeScript
|
||||
run: npm run typecheck
|
||||
continue-on-error: true
|
||||
|
||||
Reference in New Issue
Block a user