mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-28 13:39:28 +07:00
* move utils * move utils * move utils * update * update * update * update * update * refactor to clean the tests * fix release workflow * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * try to fix client db migration issue * fix tests
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
/* eslint-disable import/newline-after-import,import/first */
|
|
import '@testing-library/jest-dom';
|
|
import { theme } from 'antd';
|
|
// mock indexedDB to test with dexie
|
|
// refs: https://github.com/dumbmatter/fakeIndexedDB#dexie-and-other-indexeddb-api-wrappers
|
|
import 'fake-indexeddb/auto';
|
|
import React from 'react';
|
|
import { vi } from 'vitest';
|
|
|
|
// Global mock for @lobehub/analytics/react to avoid AnalyticsProvider dependency
|
|
// This prevents tests from failing when components use useAnalytics hook
|
|
vi.mock('@lobehub/analytics/react', () => ({
|
|
useAnalytics: () => ({
|
|
analytics: {
|
|
track: vi.fn(),
|
|
},
|
|
}),
|
|
}));
|
|
|
|
// node runtime
|
|
if (typeof window === 'undefined') {
|
|
// test with polyfill crypto
|
|
const { Crypto } = await import('@peculiar/webcrypto');
|
|
|
|
Object.defineProperty(global, 'crypto', {
|
|
value: new Crypto(),
|
|
writable: true,
|
|
});
|
|
}
|
|
|
|
// remove antd hash on test
|
|
theme.defaultConfig.hashed = false;
|
|
|
|
// 将 React 设置为全局变量,这样就不需要在每个测试文件中导入它了
|
|
(global as any).React = React;
|