cherry-studio/vitest.config.ts
one 2dedd95fcc feat: code tools, editor, executor (#4632)
* feat: code tools, editor, executor

CodeEditor & Preview
- CodeEditor: CodeMirror 6
  - Switch to CodeEditor in the settings
  - Support edit&save with a accurate diff&lookup strategy
  - Use CodeEditor for editing MCP json configuration
- CodePreview: Original Shiki syntax highlighting
  - Implemented using a custom Shiki stream tokenizer
  - Remov code caching as it is incompatible with the current streaming code highlighting
  - Add a webworker for shiki
- Other preview components
  - Merge MermaidPopup and Mermaid to MermaidPreview, use local mermaidjs
  - Show mermaid syntax error message on demand
  - Rename PlantUML to PlantUmlPreview
- Rename SyntaxHighlighterProvider to CodeStyleProvider for clarity
- Both light and dark themes are preserved for convenience

CodeToolbar
- Top sticky toolbar provides quick tools (left) and core tools (right)
- Quick tools are hidden under the `More` button to avoid clutter, while core tools are always visible
- View&edit mode
  - Allow switching between preview and edit modes
  - Add a split view

Code execution
- Pyodide for executing Python scripts
- Add a webworker for Pyodide

* fix: migrate version and lint error

* refactor: use constants for defining tool specs

* refactor: add user-select, fix tool specs

* refactor: simplify some state changing

* fix: make sure editor tools registered after the editor is ready

---------

Co-authored-by: 自由的世界人 <3196812536@qq.com>
2025-05-16 13:53:44 +08:00

57 lines
1.5 KiB
TypeScript

import { defineConfig } from 'vitest/config'
import electronViteConfig from './electron.vite.config'
const rendererConfig = electronViteConfig.renderer
export default defineConfig({
// 复用 renderer 插件和路径别名
// @ts-ignore plugins 类型
plugins: rendererConfig?.plugins,
resolve: {
// @ts-ignore alias 类型
alias: rendererConfig?.resolve.alias
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['@vitest/web-worker', './src/renderer/__tests__/setup.ts'],
include: [
// 只测试渲染进程
'src/renderer/**/*.{test,spec}.{ts,tsx}',
'src/renderer/**/__tests__/**/*.{test,spec}.{ts,tsx}'
],
exclude: ['**/node_modules/**', '**/dist/**', '**/out/**', '**/build/**', '**/src/renderer/__tests__/setup.ts'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/out/**',
'**/build/**',
'**/coverage/**',
'**/.yarn/**',
'**/.cursor/**',
'**/.vscode/**',
'**/.github/**',
'**/.husky/**',
'**/*.d.ts',
'**/types/**',
'**/__tests__/**',
'**/*.{test,spec}.{ts,tsx}',
'**/*.config.{js,ts}',
'**/electron.vite.config.ts',
'**/vitest.config.ts'
]
},
testTimeout: 20000,
pool: 'threads',
poolOptions: {
threads: {
singleThread: false
}
}
}
})