hookehuyr

fix(mock): 修复小程序环境 process 不存在的错误

在小程序环境中 process 对象不存在,导致 isAITestEnvironment
函数抛出 ReferenceError。

修复:添加 typeof process !== 'undefined' 检查

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
...@@ -118,8 +118,8 @@ export const clearSessionId = () => { ...@@ -118,8 +118,8 @@ export const clearSessionId = () => {
118 * - @returns {boolean} true=测试环境,false=非测试环境 118 * - @returns {boolean} true=测试环境,false=非测试环境
119 */ 119 */
120 const isAITestEnvironment = () => { 120 const isAITestEnvironment = () => {
121 - // 检测 Vitest 环境变量 121 + // 检测 Vitest 环境变量(小程序环境没有 process,需要先检查)
122 - if (process.env.VITEST === 'true') { 122 + if (typeof process !== 'undefined' && process.env && process.env.VITEST === 'true') {
123 return true 123 return true
124 } 124 }
125 // 检测全局 __vitest__ 标记 125 // 检测全局 __vitest__ 标记
......