-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathvitest.config.mts
More file actions
32 lines (29 loc) · 1.63 KB
/
Copy pathvitest.config.mts
File metadata and controls
32 lines (29 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import path from 'node:path'
import {defineConfig} from 'vitest/config'
const aliasObj = {
'@main': path.resolve('src/main'),
'@preload': path.resolve('src/preload'),
'@renderer': path.resolve('src/renderer/src'),
'@shared': path.resolve('src/shared'),
'yt-dlp-bridge/parsers': path.resolve('packages/yt-dlp-bridge/src/parsers.ts'),
'yt-dlp-bridge/redaction': path.resolve('packages/yt-dlp-bridge/src/redaction.ts'),
'yt-dlp-bridge': path.resolve('packages/yt-dlp-bridge/src/index.ts'),
'ytdlp-errors': path.resolve('packages/ytdlp-errors/src/index.ts'),
'electron-log/main.js': path.resolve('tests/__mocks__/electron-log-main.ts'),
'electron-log/renderer.js': path.resolve('tests/__mocks__/electron-log-renderer.ts'),
electron: path.resolve('tests/__mocks__/electron.ts')
}
// `unplugin-icons` virtual modules (`~icons/simple-icons/x`,
// `~icons/logos/facebook`, etc.) are generated by the Vite plugin at build
// time. Vitest doesn't run that plugin — without a regex alias, every test
// that transitively imports ShareDialog crashes on import resolution. Map
// every `~icons/*` to a single inert SVG stub.
const alias = [...Object.entries(aliasObj).map(([find, replacement]) => ({find, replacement})), {find: /^~icons\/.*/, replacement: path.resolve('tests/__mocks__/icons-stub.tsx')}]
export default defineConfig({
test: {
projects: [
{resolve: {alias}, test: {name: 'node', globals: true, include: ['tests/**/*.test.ts'], environment: 'node', setupFiles: ['tests/setup.ts']}},
{resolve: {alias}, test: {name: 'jsdom', globals: true, include: ['tests/**/*.test.tsx'], environment: 'jsdom', setupFiles: ['tests/setup.ts']}}
]
}
})