mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
* 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
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import '@testing-library/jest-dom/vitest'
|
|
|
|
import { styleSheetSerializer } from 'jest-styled-components/serializer'
|
|
import { expect, vi } from 'vitest'
|
|
|
|
expect.addSnapshotSerializer(styleSheetSerializer)
|
|
|
|
vi.mock('electron-log/renderer', () => {
|
|
return {
|
|
default: {
|
|
info: console.log,
|
|
error: console.error,
|
|
warn: console.warn,
|
|
debug: console.debug,
|
|
verbose: console.log,
|
|
silly: console.log,
|
|
log: console.log,
|
|
transports: {
|
|
console: {
|
|
level: 'info'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
vi.mock('axios', () => ({
|
|
default: {
|
|
get: vi.fn().mockResolvedValue({ data: {} }), // Mocking axios GET request
|
|
post: vi.fn().mockResolvedValue({ data: {} }) // Mocking axios POST request
|
|
// You can add other axios methods like put, delete etc. as needed
|
|
}
|
|
}))
|
|
|
|
vi.stubGlobal('electron', {
|
|
ipcRenderer: {
|
|
on: vi.fn(),
|
|
send: vi.fn()
|
|
}
|
|
})
|
|
vi.stubGlobal('api', {
|
|
file: {
|
|
read: vi.fn().mockResolvedValue('[]'),
|
|
writeWithId: vi.fn().mockResolvedValue(undefined)
|
|
}
|
|
})
|