test: 引入 Vitest 并覆盖 variant / credit-package-names 纯函数模块 - #131
Merged
Merged
Conversation
- 新增 vitest.config.ts:独立于 vite.config.ts,仅含 @ 别名与 test.include(node 环境) - package.json 增加 test script(vitest run),同步 package-lock(vitest 5.0.2) - 新增 src/lib/variant.test.ts(14 例)、src/lib/credit-package-names.test.ts(10 例) - .github/workflows/test.yml 新增 frontend-tests job(npm ci + npm test)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动清单
vitest.config.ts(新增):独立于vite.config.ts的测试配置,只保留@别名与test.include(src/**/*.test.ts),environment 为 nodepackage.json/package-lock.json:新增 devDependencyvitest@^5.0.2,新增testscript(vitest run)src/lib/variant.test.ts(新增,14 例):normalizeVariant宽松解析、各档位文案/域名映射、accountVariant缺省处理、能力开关src/lib/credit-package-names.test.ts(新增,10 例):官方商品码命中映射、未命中回落链packageName → packageCode → fallback、空值边界.github/workflows/test.yml:新增frontend-testsjob(ubuntu-latest,npm ci+npm test,不依赖 Rust 工具链)本地验证
npm testnpx tsc --noEmitnpm run build说明
src/lib/account-display.ts不在 main 上(属 feat(accounts): 账号信息弹框与每账号显示字段 #127),其测试未包含在本 PR,待该模块进入 main 后另补。@jridgewell/sourcemap-codec、picomatch各有一个 semver 范围内的小版本更新,由npm install解析带入。