|
@@ -1,6 +1,10 @@
|
|
|
// 测试环境全局设置
|
|
// 测试环境全局设置
|
|
|
import { beforeAll, afterAll, afterEach, vi, expect } from 'vitest';
|
|
import { beforeAll, afterAll, afterEach, vi, expect } from 'vitest';
|
|
|
import * as matchers from '@testing-library/jest-dom/matchers';
|
|
import * as matchers from '@testing-library/jest-dom/matchers';
|
|
|
|
|
+import dotenv from 'dotenv';
|
|
|
|
|
+
|
|
|
|
|
+// 加载环境变量
|
|
|
|
|
+dotenv.config();
|
|
|
|
|
|
|
|
// 全局测试超时设置已在 vitest.config.ts 中配置
|
|
// 全局测试超时设置已在 vitest.config.ts 中配置
|
|
|
|
|
|
|
@@ -12,11 +16,13 @@ beforeAll(() => {
|
|
|
// 设置测试环境变量
|
|
// 设置测试环境变量
|
|
|
process.env.NODE_ENV = 'test';
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
- // 抑制控制台输出(测试中)
|
|
|
|
|
|
|
+ // 抑制控制台输出(测试中),但保留console.debug用于调试
|
|
|
vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
|
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
|
vi.spyOn(console, 'info').mockImplementation(() => {});
|
|
vi.spyOn(console, 'info').mockImplementation(() => {});
|
|
|
|
|
+
|
|
|
|
|
+ // console.debug保持可用,用于调试信息
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 全局测试后置清理
|
|
// 全局测试后置清理
|