mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-04-07 14:21:26 -07:00
In Electron 41, ELECTRON_RUN_AS_NODE mode uses Chromium-based fetch which requires Blink's AbortSignal. Node.js AbortSignal fails the instanceof check. Fixes: - vitest.config.ts: set features/** to node environment via environmentMatchGlobs so HTTP-only tests use Node.js fetch (not Chromium fetch) - setup-vitest.ts: guard all document/window access behind typeof document check so setup is safe in both jsdom and node environments - callProviderAPI.ts: no change needed (signal issue is env-specific)
78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
import path from 'path';
|
|
import swc from 'unplugin-swc';
|
|
import { defineConfig } from 'vitest/config';
|
|
|
|
export default defineConfig({
|
|
plugins: [swc.vite({
|
|
jsc: {
|
|
transform: {
|
|
react: {
|
|
runtime: 'automatic',
|
|
},
|
|
},
|
|
},
|
|
})],
|
|
|
|
test: {
|
|
// Test environment
|
|
environment: 'jsdom',
|
|
|
|
// features/ tests (HTTP/Node.js integration) run in node environment; src/ tests need jsdom
|
|
environmentMatchGlobs: [
|
|
['features/**', 'node'],
|
|
],
|
|
|
|
// Setup files
|
|
setupFiles: ['./src/__tests__/setup-vitest.ts'],
|
|
|
|
// Test file patterns
|
|
include: [
|
|
'src/**/__tests__/**/*.(test|spec).(ts|tsx|js)',
|
|
'src/**/*.(test|spec).(ts|tsx|js)',
|
|
'features/**/*.(test|spec).(ts|tsx|js)',
|
|
],
|
|
|
|
// Global test settings - this makes vi, expect, etc. available globally
|
|
globals: true,
|
|
|
|
// Coverage settings
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'html', 'lcov'],
|
|
include: [
|
|
'src/**/*.{ts,tsx}',
|
|
],
|
|
exclude: [
|
|
'src/**/*.d.ts',
|
|
'src/__tests__/**/*',
|
|
'src/main.ts',
|
|
'src/preload/**/*',
|
|
],
|
|
},
|
|
|
|
pool: 'forks',
|
|
poolOptions: {
|
|
forks: {
|
|
maxForks: 6,
|
|
minForks: 2,
|
|
},
|
|
isolate: true,
|
|
},
|
|
|
|
testTimeout: 30000,
|
|
hookTimeout: 30000,
|
|
reporters: ['default', 'hanging-process'],
|
|
},
|
|
|
|
resolve: {
|
|
alias: [
|
|
{ find: '@', replacement: path.resolve(__dirname, './src') },
|
|
{ find: '@services', replacement: path.resolve(__dirname, './src/services') },
|
|
// Stub optional MCP SDK so tests don't fail on import-resolution when SDK is not installed
|
|
{ find: /^@modelcontextprotocol\/sdk\/.*$/, replacement: path.resolve(__dirname, './src/__tests__/__stubs__/mcpSdkStub.ts') },
|
|
],
|
|
},
|
|
|
|
// Handle CSS and static assets
|
|
assetsInclude: ['**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.gif', '**/*.svg'],
|
|
});
|