cherry-studio/vitest.config.ts
one 665a62080b
test: more unit tests (#5130)
* test: more unit tests

- Adjust vitest configuration to handle main process and renderer process tests separately
- Add unit tests for main process utils
- Add unit tests for the renderer process
- Add three component tests to verify vitest usage: `DragableList`, `Scrollbar`, `QuickPanelView`
- Add an e2e startup test to verify playwright usage
- Extract `splitApiKeyString` and add tests for it
- Add and format some comments

* fix: mock individual properties

* test: add tests for CustomTag

* test: add tests for ExpandableText

* test: conditional rendering tooltip of tag

* chore: update dependencies
2025-05-26 16:50:26 +08:00

74 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',
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
}
}
}
})