test(apps/app): set up Vitest harness — closes TECH-APP-VITEST (WS-6)
Mirrors apps/portal's Vitest setup so the SPA can take frontend unit + component tests. Required prerequisite for WS-6 sessie 3b's admin UI work — apps/portal had 113+ tests, apps/app had zero, and launching WS-6's organizer UI uncovered while the portal SPA is well-tested would be asymmetric quality. Setup: - vitest, happy-dom, @vue/test-utils, @testing-library/vue installed - vitest.config.ts mirrors portal config: trimmed auto-imports (no pinia/vue-router/vue-i18n/@vueuse/math) so tests run fast in happy-dom without loading the full Vuexy bundle - AutoImport's dts:false prevents the trimmed test-only set from clobbering the dev-server's full auto-imports.d.ts (apps/app's auto-import surface is bigger than the portal's) - tests/setup.ts mocks vue-router by default; tests that exercise the real router can override per-suite - Sample sanity test confirms the harness works end-to-end Adds `pnpm test` and `pnpm test:watch` scripts to package.json. Refs: BACKLOG TECH-APP-VITEST, WS-6 sessie 3b prerequisite Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
apps/app/vitest.config.ts
Normal file
37
apps/app/vitest.config.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
// Dedicated Vitest config — intentionally trimmed down from vite.config.ts.
|
||||
// Skip Vuetify / MetaLayouts / VueRouter plugins so unit tests run fast in
|
||||
// happy-dom without loading the full Vuexy bundle. Mirrors apps/portal/vitest.config.ts.
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
imports: ['vue', '@vueuse/core'],
|
||||
dirs: ['./src/@core/utils', './src/@core/composable/', './src/composables/', './src/utils/'],
|
||||
vueTemplate: true,
|
||||
// Don't write to auto-imports.d.ts — vite.config.ts owns that file
|
||||
// with the full app's auto-import set. Trimmed test-only set must
|
||||
// not clobber the IDE typings for the running dev server.
|
||||
dts: false,
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
'@core': fileURLToPath(new URL('./src/@core', import.meta.url)),
|
||||
'@layouts': fileURLToPath(new URL('./src/@layouts', import.meta.url)),
|
||||
'@images': fileURLToPath(new URL('./src/assets/images/', import.meta.url)),
|
||||
'@styles': fileURLToPath(new URL('./src/assets/styles/', import.meta.url)),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
include: ['tests/**/*.{test,spec}.ts', 'src/**/__tests__/**/*.{test,spec}.ts'],
|
||||
setupFiles: ['./tests/setup.ts'],
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user