You need to sign in or sign up before continuing.
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 = () => {
* - @returns {boolean} true=测试环境,false=非测试环境
*/
const isAITestEnvironment = () => {
// 检测 Vitest 环境变量
if (process.env.VITEST === 'true') {
// 检测 Vitest 环境变量(小程序环境没有 process,需要先检查)
if (typeof process !== 'undefined' && process.env && process.env.VITEST === 'true') {
return true
}
// 检测全局 __vitest__ 标记
......