Files
hms/apps/miniprogram/__tests__/setup.ts
iven 935ca70dfa test(mp): service 层测试扩展 — health + consultation + request
新增 3 个测试文件(+23 个测试用例),总计 9 文件 75 测试:
- request.test.ts: HTTP 方法、查询参数构建、缓存、错误处理
- health.test.ts: 体征录入字段映射、日常监测、阈值查找
- consultation.test.ts: 咨询会话/消息 CRUD、已读标记

- 添加 vitest setup.ts mock @tarojs/taro 和 @tarojs/runtime
- vitest.config.ts 增加 setupFiles 配置

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 14:10:27 +08:00

24 lines
586 B
TypeScript

// Global setup for Taro runtime compatibility in tests
// Mock @tarojs/taro before any module loads it
import { vi } from 'vitest';
vi.mock('@tarojs/taro', () => ({
default: {
getStorageSync: vi.fn(() => ''),
setStorageSync: vi.fn(),
removeStorageSync: vi.fn(),
showToast: vi.fn(),
hideToast: vi.fn(),
showLoading: vi.fn(),
hideLoading: vi.fn(),
request: vi.fn(),
reLaunch: vi.fn(),
navigateTo: vi.fn(),
redirectTo: vi.fn(),
switchTab: vi.fn(),
getCurrentPages: vi.fn(() => []),
},
}));
vi.mock('@tarojs/runtime', () => ({}));