cherry-studio/vitest.config.ts
fullex 40f9601379
refactor: Unified Logger / 统一日志管理 (#8207)
* Revert "feat: optimize minapp cache with LRU (#8160)"

This reverts commit f0043b4be5.

* feat: integrate logger service and enhance logging throughout the application

- Added a new LoggerService to standardize logging across the application.
- Replaced console.error and console.warn calls with logger methods for improved consistency and error tracking.
- Introduced a new IPC channel for logging messages to the main process.
- Updated various components and services to utilize the new logging system, enhancing error handling and debugging capabilities.

* refactor: enhance logging and error handling across various components

- Integrated the LoggerService for consistent logging throughout the application.
- Updated multiple components and services to utilize the new logging system, improving error tracking and debugging capabilities.
- Refactored file handling and error management in several services to enhance reliability and clarity.
- Improved the structure and readability of the codebase by removing redundant checks and simplifying logic.

* chore: update TypeScript configuration and enhance test setup

- Added test mock paths to tsconfig.web.json for improved test coverage.
- Configured Vitest to include a setup file for main tests, ensuring consistent test environment.
- Updated IPC logger context for better clarity in logging.
- Enhanced LoggerService to handle undefined values gracefully.
- Mocked LoggerService globally in renderer tests to streamline testing process.

* refactor: standardize logging across ProxyManager and ReduxService

- Replaced instances of Logger with logger for consistent logging implementation.
- Improved logging clarity in ProxyManager's configureProxy method and ReduxService's state handling.
- Enhanced error logging in ReduxService to align with the new logging system.

* refactor: reorganize LoggerService for improved clarity and consistency

- Moved the definition of SYSTEM_INFO, APP_VERSION, and DEFAULT_LEVEL to enhance code organization.
- Simplified the getIsDev function in the renderer LoggerService for better readability.
- Updated logging conditions to ensure messages are logged correctly based on context.

* docs: add usage instructions for LoggerService and clean up logging code

- Included important usage instructions for LoggerService in both English and Chinese.
- Commented out the console transport in LoggerService to streamline logging.
- Improved logging message formatting in MCPService for clarity.
- Removed redundant logging statements in SelectionService to enhance code cleanliness.

* refactor: update LoggerService documentation paths and enhance logging implementation

- Changed the documentation paths for LoggerService usage instructions to `docs/technical/how-to-use-logger-en.md` and `docs/technical/how-to-use-logger-zh.md`.
- Replaced console logging with the loggerService in various components, including `MCPSettings`, `BlockManager`, and multiple callback files, to ensure consistent logging practices across the application.
- Improved the clarity and context of log messages for better debugging and monitoring.

* docs: emphasize logger usage guidelines in documentation

- Added a note in both English and Chinese documentation to discourage the use of `console.xxx` for logging unless necessary, promoting consistent logging practices across the application.
2025-07-18 09:40:56 +08:00

75 lines
1.9 KiB
TypeScript

import { defineConfig } from 'vitest/config'
import electronViteConfig from './electron.vite.config'
const mainConfig = (electronViteConfig as any).main
const rendererConfig = (electronViteConfig as any).renderer
export default defineConfig({
test: {
workspace: [
// 主进程单元测试配置
{
extends: true,
plugins: mainConfig.plugins,
resolve: {
alias: mainConfig.resolve.alias
},
test: {
name: 'main',
environment: 'node',
setupFiles: ['tests/main.setup.ts'],
include: ['src/main/**/*.{test,spec}.{ts,tsx}', 'src/main/**/__tests__/**/*.{test,spec}.{ts,tsx}']
}
},
// 渲染进程单元测试配置
{
extends: true,
plugins: rendererConfig.plugins,
resolve: {
alias: rendererConfig.resolve.alias
},
test: {
name: 'renderer',
environment: 'jsdom',
setupFiles: ['@vitest/web-worker', 'tests/renderer.setup.ts'],
include: ['src/renderer/**/*.{test,spec}.{ts,tsx}', 'src/renderer/**/__tests__/**/*.{test,spec}.{ts,tsx}']
}
}
],
// 全局共享配置
globals: true,
setupFiles: [],
exclude: ['**/node_modules/**', '**/dist/**', '**/out/**', '**/build/**'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov', 'text-summary'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/out/**',
'**/build/**',
'**/coverage/**',
'**/tests/**',
'**/.yarn/**',
'**/.cursor/**',
'**/.vscode/**',
'**/.github/**',
'**/.husky/**',
'**/*.d.ts',
'**/types/**',
'**/__tests__/**',
'**/*.{test,spec}.{ts,tsx}',
'**/*.config.{js,ts}'
]
},
testTimeout: 20000,
pool: 'threads',
poolOptions: {
threads: {
singleThread: false
}
}
}
})