Ch33. 测试策略
单元测试与集成测试的边界划分。
本章概要
AutoSnippet 使用 Vitest 作为测试框架,测试分为单元测试和集成测试。本章解析测试的组织方式、mock 策略和 CI 集成。
测试分层
单元测试 (test/unit/)
集成测试 (test/integration/)
Mock 策略
CI 集成
GitHub Actions:
build → lint → dashboard build → unit tests → integration tests测试命令
bash
npm run test:unit # 单元测试
npm run test:integration # 集成测试
npx vitest run test/path # 单文件测试