feat(image): 新建 knowai-core:1.0.0 镜像并完成推送
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
- 搭建 api、auth、utils 等逻辑模块 - 通过 tsc、eslint、vitest 测试验证 BREAKING CHANGE: 新镜像分支
This commit is contained in:
53
test/setup.ts
Normal file
53
test/setup.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 测试设置文件
|
||||
* 配置全局测试环境和共享设置
|
||||
*/
|
||||
|
||||
import { vi } from 'vitest';
|
||||
|
||||
// 模拟浏览器API
|
||||
Object.defineProperty(window, 'localStorage', {
|
||||
value: {
|
||||
getItem: vi.fn(),
|
||||
setItem: vi.fn(),
|
||||
removeItem: vi.fn(),
|
||||
clear: vi.fn()
|
||||
},
|
||||
writable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(window, 'sessionStorage', {
|
||||
value: {
|
||||
getItem: vi.fn(),
|
||||
setItem: vi.fn(),
|
||||
removeItem: vi.fn(),
|
||||
clear: vi.fn()
|
||||
},
|
||||
writable: true
|
||||
});
|
||||
|
||||
// 模拟IntersectionObserver
|
||||
globalThis.IntersectionObserver = vi.fn().mockImplementation(() => ({
|
||||
observe: vi.fn(),
|
||||
unobserve: vi.fn(),
|
||||
disconnect: vi.fn()
|
||||
}));
|
||||
|
||||
// 模拟ResizeObserver
|
||||
globalThis.ResizeObserver = vi.fn().mockImplementation(() => ({
|
||||
observe: vi.fn(),
|
||||
unobserve: vi.fn(),
|
||||
disconnect: vi.fn()
|
||||
}));
|
||||
|
||||
// 模拟requestAnimationFrame
|
||||
globalThis.requestAnimationFrame = vi.fn((cb: FrameRequestCallback) => setTimeout(cb, 0));
|
||||
|
||||
// 模拟cancelAnimationFrame
|
||||
globalThis.cancelAnimationFrame = vi.fn((id: number) => clearTimeout(id));
|
||||
|
||||
// 模拟fetch
|
||||
globalThis.fetch = vi.fn();
|
||||
|
||||
// 设置环境变量
|
||||
process.env.NODE_ENV = 'test';
|
||||
Reference in New Issue
Block a user