chore(ui): add Vitest + Testing Library scaffolding

Prepares for Plan 03 unit tests (MustacheEditor, NotificationBell, wizard step
validation). jsdom environment + jest-dom matchers + canary test verifies the
wiring.
This commit is contained in:
hsiegeln
2026-04-20 12:16:22 +02:00
parent 2942025a54
commit 0aa1776b57
5 changed files with 1246 additions and 2 deletions

1209
ui/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,9 @@
"preview": "vite preview",
"generate-api": "openapi-typescript src/api/openapi.json -o src/api/schema.d.ts",
"generate-api:live": "curl -s http://192.168.50.86:30090/api/v1/api-docs -o src/api/openapi.json && openapi-typescript src/api/openapi.json -o src/api/schema.d.ts",
"test": "vitest run",
"test:watch": "vitest",
"test:ui": "vitest --ui",
"postinstall": "node -e \"const fs=require('fs');fs.mkdirSync('public',{recursive:true});fs.copyFileSync('node_modules/@cameleer/design-system/assets/cameleer-logo.svg','public/favicon.svg')\""
},
"dependencies": {
@@ -30,19 +33,25 @@
"devDependencies": {
"@eslint/js": "^9.39.4",
"@playwright/test": "^1.58.2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.1",
"@types/js-yaml": "^4.0.9",
"@types/node": "^24.12.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.0",
"@vitest/ui": "^4.1.4",
"cross-env": "^10.1.0",
"eslint": "^9.39.4",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.4.0",
"jsdom": "^29.0.2",
"openapi-typescript": "^7.13.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.56.1",
"vite": "^8.0.0"
"vite": "^8.0.0",
"vitest": "^4.1.4"
}
}

View File

@@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest';
describe('vitest canary', () => {
it('arithmetic still works', () => {
expect(1 + 1).toBe(2);
});
});

7
ui/src/test/setup.ts Normal file
View File

@@ -0,0 +1,7 @@
import '@testing-library/jest-dom/vitest';
import { cleanup } from '@testing-library/react';
import { afterEach } from 'vitest';
afterEach(() => {
cleanup();
});

14
ui/vitest.config.ts Normal file
View File

@@ -0,0 +1,14 @@
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./src/test/setup.ts'],
include: ['src/**/*.test.{ts,tsx}'],
exclude: ['src/test/e2e/**', 'node_modules/**'],
css: true,
},
});