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:
Generated
+20
@@ -108,6 +108,7 @@
|
||||
"husky": "9.1.7",
|
||||
"lint-staged": "17.0.5",
|
||||
"prettier": "3.8.3",
|
||||
"tsx": "4.22.4",
|
||||
"typescript": "6.0.3",
|
||||
"vite": "8.0.14",
|
||||
"vite-plugin-pwa": "1.3.0",
|
||||
@@ -12357,6 +12358,25 @@
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
"version": "4.22.4",
|
||||
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.22.4.tgz",
|
||||
"integrity": "sha512-X8EX+XV4QR5xCsrgxaED954zTDfY8KqlDtskKEL0cHhyS/P8b4IFOvGDQpsC9Q1XnLq915wEfwwY/zzskCtmhg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "~0.28.0"
|
||||
},
|
||||
"bin": {
|
||||
"tsx": "dist/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
|
||||
Reference in New Issue
Block a user