chore(desktop): add Vitest + testing-library

Install Vitest, @testing-library/react, jest-dom, jsdom. Add test + test:watch scripts. Mirrors ui/web vitest config.
This commit is contained in:
viettranx committed 2026-04-15 11:24:57 +07:00
1 parent 3b4004946e
commit 4cd79eacd7
5 files changed
+789 -2

No files matched your search

+8 -2
View File
@@ -6,7 +6,9 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",
@@ -30,12 +32,16 @@
},
"devDependencies": {
"@tailwindcss/vite": "^4.2.2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@types/react-syntax-highlighter": "^15.5.13",
"@vitejs/plugin-react": "^6.0.1",
"jsdom": "^29.0.2",
"tailwindcss": "^4.2.2",
"typescript": "^6.0.2",
"vite": "^8.0.8"
"vite": "^8.0.8",
"vitest": "^4.1.4"
}
}
+744
View File
File diff suppressed because it is too large. Load diff
+15
View File
@@ -0,0 +1,15 @@
import '@testing-library/jest-dom'
// Mock HTMLMediaElement — jsdom doesn't implement audio playback
Object.defineProperty(window.HTMLMediaElement.prototype, 'play', {
configurable: true,
value: () => Promise.resolve(),
})
Object.defineProperty(window.HTMLMediaElement.prototype, 'pause', {
configurable: true,
value: () => undefined,
})
Object.defineProperty(window.HTMLMediaElement.prototype, 'load', {
configurable: true,
value: () => undefined,
})
@@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest'
describe('vitest sanity', () => {
it('boots', () => {
expect(true).toBe(true)
})
})
+15
View File
@@ -0,0 +1,15 @@
import { defineConfig } from 'vitest/config'
import path from 'path'
export default defineConfig({
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./src/test/setup.ts'],
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})