test: add test infrastructure for frontend and server
- Frontend: vitest.config.ts with vue plugin + jsdom, dummy component test - Server: in-memory SQLite test DB factory + Hono testClient helper + smoke test - CI: add pnpm audit and server coverage threshold steps - Root: vitest workspace config for multi-project test discovery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6f0eb92ebb
commit
d9e32123fe
@@ -16,7 +16,10 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.2.1",
|
||||
"@testing-library/vue": "^8.1.0",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"jsdom": "^28.1.0",
|
||||
"tailwindcss": "^4.2.1",
|
||||
"typescript": "^5.7.3",
|
||||
"vite": "^7.3.1",
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import DummyComponent from './DummyComponent.vue'
|
||||
|
||||
describe('DummyComponent', () => {
|
||||
it('renders the message prop as text content', () => {
|
||||
const wrapper = mount(DummyComponent, {
|
||||
props: { message: 'BOTFIGHTS' },
|
||||
})
|
||||
expect(wrapper.text()).toBe('BOTFIGHTS')
|
||||
})
|
||||
|
||||
it('renders different message', () => {
|
||||
const wrapper = mount(DummyComponent, {
|
||||
props: { message: 'Stack sats, fight bots' },
|
||||
})
|
||||
expect(wrapper.text()).toBe('Stack sats, fight bots')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{ message: string }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="dummy">{{ message }}</div>
|
||||
</template>
|
||||
@@ -0,0 +1,2 @@
|
||||
// Frontend test setup for @vue/test-utils + jsdom
|
||||
// Add global test utilities and mocks here as needed
|
||||
@@ -0,0 +1,18 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { resolve } from 'path'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
include: ['src/**/*.test.ts'],
|
||||
setupFiles: ['src/test-setup.ts'],
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user