Fixed tests

This commit is contained in:
2026-02-12 01:27:33 +01:00 Verified
parent 21a7e64d10
commit 8ee8b76cb2
8 changed files with 1210 additions and 6 deletions
Binary file not shown.
+1168 -2
View File
File diff suppressed because it is too large Load Diff
+7 -2
View File
@@ -7,7 +7,8 @@
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"lint": "eslint .", "lint": "eslint .",
"preview": "vite preview" "preview": "vite preview",
"test": "vitest"
}, },
"dependencies": { "dependencies": {
"react": "^19.2.0", "react": "^19.2.0",
@@ -15,6 +16,8 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.39.1", "@eslint/js": "^9.39.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.7", "@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1", "@vitejs/plugin-react": "^5.1.1",
@@ -22,6 +25,8 @@
"eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24", "eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0", "globals": "^16.5.0",
"vite": "^7.3.1" "jsdom": "^28.0.0",
"vite": "^7.3.1",
"vitest": "^4.0.18"
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
// frontend/src/App.jsx // frontend/src/App.jsx
import { useState } from 'react' import { useState } from 'react'
import reactLogo from './assets/react.svg' import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg' import viteLogo from './assets/vite.svg'
import './App.css' import './App.css'
function App() { function App() {
+16
View File
@@ -0,0 +1,16 @@
// frontend/src/App.test.jsx
import { render, screen } from '@testing-library/react';
import { expect, test } from 'vitest';
import App from './App';
test('renders the Vite and React logos', () => {
// 1. Render the component
render(<App />);
// 2. Search for elements
const heading = screen.getByText(/Vite \+ React/i);
// 3. Assert (the "expect" part)
expect(heading).toBeInTheDocument();
});

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

+15 -1
View File
@@ -1,7 +1,21 @@
// frontend/vite.config.js
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import path from 'path'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
}) test: {
globals: true,
environment: 'jsdom',
setupFiles: './vitest.setup.js',
css: true,
},
resolve: {
alias: {
// This ensures that /vite.svg points to the public folder correctly
"/": path.resolve(__dirname, "./public"),
},
},
})
+3
View File
@@ -0,0 +1,3 @@
// frontend/vitest.setup.js
import '@testing-library/jest-dom/vitest';