From 8ad1e6291e6b22f6574191db306dc4f0cbf609d2 Mon Sep 17 00:00:00 2001 From: FORGE Date: Fri, 10 Apr 2026 14:27:53 +0000 Subject: [PATCH 1/4] feat: Set up React+Vite project configuration Run: e33bf8c7-24d6-41ab-a25b-df1c845f66c1 Task: fc120e40-4d56-4697-b670-48c2e52b65ba Agent: builder --- RUNNING.md | 130 ++++++++++++++++++++++++++++++++---- frontend/.eslintrc.json | 35 ++++++++++ frontend/Dockerfile | 19 ++++++ frontend/docker-compose.yml | 18 +++++ frontend/package.json | 35 ++++++++++ frontend/public/index.html | 12 ++++ frontend/src/App.test.tsx | 17 +++++ frontend/src/App.tsx | 15 +++++ frontend/src/index.css | 31 +++++++++ frontend/src/main.tsx | 20 ++++++ frontend/src/setupTests.ts | 5 ++ frontend/src/vite-env.d.ts | 1 + frontend/tsconfig.json | 25 +++++++ frontend/tsconfig.node.json | 10 +++ frontend/vite.config.ts | 18 +++++ 15 files changed, 379 insertions(+), 12 deletions(-) create mode 100644 frontend/.eslintrc.json create mode 100644 frontend/Dockerfile create mode 100644 frontend/docker-compose.yml create mode 100644 frontend/package.json create mode 100644 frontend/public/index.html create mode 100644 frontend/src/App.test.tsx create mode 100644 frontend/src/App.tsx create mode 100644 frontend/src/index.css create mode 100644 frontend/src/main.tsx create mode 100644 frontend/src/setupTests.ts create mode 100644 frontend/src/vite-env.d.ts create mode 100644 frontend/tsconfig.json create mode 100644 frontend/tsconfig.node.json create mode 100644 frontend/vite.config.ts diff --git a/RUNNING.md b/RUNNING.md index 77896cf..d44c9e0 100644 --- a/RUNNING.md +++ b/RUNNING.md @@ -1,33 +1,139 @@ -# Running the Todo API +# Hello World React+Vite Application + +## TEAM_BRIEF +stack: TypeScript/React+Vite +test_runner: cd frontend && npx vitest run +lint_tool: cd frontend && npx eslint src/ --ext .ts,.tsx +coverage_tool: none +coverage_threshold: 0 +coverage_applies: false + +## Overview + +A minimal React application built with Vite and TypeScript that displays "Hello World". ## Prerequisites -- Python 3.10 or later +- **Docker** and **Docker Compose** installed, OR +- **Node.js 18+** and **npm** installed locally + +--- + +## Docker Setup (Recommended) + +### 1. Build and start the container + +```bash +cd frontend +docker compose up --build +``` + +### 2. Access the app + +Open your browser and navigate to: + +``` +http://localhost:5173 +``` + +You should see **"Hello World"** displayed on the page. + +### 3. Run tests inside Docker + +```bash +cd frontend +docker compose run --rm app npm test +``` + +### 4. Run linting inside Docker + +```bash +cd frontend +docker compose run --rm app npm run lint +``` + +### 5. Stop the container + +```bash +cd frontend +docker compose down +``` + +--- + +## Local Setup (Without Docker) + +### 1. Install dependencies + +```bash +cd frontend +npm install +``` -## Install dependencies +### 2. Start the development server ```bash -pip install fastapi uvicorn pydantic +npm run dev ``` -For running the test suite you will also need: +Open your browser at `http://localhost:5173`. + +### 3. Run tests ```bash -pip install httpx pytest +npm test ``` -## Start the server +### 4. Run linting ```bash -uvicorn main:app --reload --host 0.0.0.0 --port 8000 +npm run lint ``` -The API will be available at . +### 5. Build for production + +```bash +npm run build +``` -Interactive docs are served at . +The production-ready files will be in the `dist/` directory. -## Run the tests +### 6. Preview production build ```bash -pytest tests/ +npm run preview ``` + +--- + +## Project Structure + +``` +frontend/ +├── public/ +│ └── index.html # HTML template with
+├── src/ +│ ├── App.tsx # Main App component (Hello World) +│ ├── App.test.tsx # Tests for App component +│ ├── index.css # Global styles +│ ├── main.tsx # Application entry point +│ ├── setupTests.ts # Test setup (jest-dom matchers) +│ └── vite-env.d.ts # Vite type declarations +├── .eslintrc.json # ESLint configuration +├── docker-compose.yml # Docker Compose service definition +├── Dockerfile # Container image definition +├── package.json # Dependencies and scripts +├── tsconfig.json # TypeScript configuration +├── tsconfig.node.json # TypeScript config for Vite +└── vite.config.ts # Vite configuration +``` + +## Available Scripts + +| Script | Command | Description | +| --------------- | ------------------- | ---------------------------------- | +| `npm run dev` | `vite` | Start development server | +| `npm run build` | `tsc && vite build` | Type-check and build for production| +| `npm run preview`| `vite preview` | Preview production build | +| `npm test` | `vitest run` | Run test suite | +| `npm run lint` | `eslint src/` | Lint source files | diff --git a/frontend/.eslintrc.json b/frontend/.eslintrc.json new file mode 100644 index 0000000..e432e0d --- /dev/null +++ b/frontend/.eslintrc.json @@ -0,0 +1,35 @@ +{ + "env": { + "browser": true, + "es2020": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2020, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "plugins": [ + "react", + "react-hooks", + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "plugin:@typescript-eslint/recommended" + ], + "settings": { + "react": { + "version": "detect" + } + }, + "rules": { + "react/react-in-jsx-scope": "off", + "react/jsx-uses-react": "off" + } +} diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..0e0ac71 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,19 @@ +# Stage 1: Development +FROM node:18-alpine AS dev + +WORKDIR /app + +# Copy package files first for better layer caching +COPY package.json ./ + +# Install dependencies +RUN npm install + +# Copy remaining source code +COPY . . + +# Expose Vite dev server port +EXPOSE 5173 + +# Start dev server +CMD ["npm", "run", "dev"] diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml new file mode 100644 index 0000000..56ddc8d --- /dev/null +++ b/frontend/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3.8" + +services: + app: + build: + context: . + dockerfile: Dockerfile + target: dev + ports: + - "5173:5173" + volumes: + - ./src:/app/src + - ./public:/app/public + - ./vite.config.ts:/app/vite.config.ts + - ./tsconfig.json:/app/tsconfig.json + - ./tsconfig.node.json:/app/tsconfig.node.json + environment: + - NODE_ENV=development diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..b280c7d --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,35 @@ +{ + "name": "hello-world-react-vite", + "private": true, + "version": "1.0.0", + "type": "module", + "description": "A modern React+Vite+TypeScript Hello World application", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview", + "test": "vitest run", + "test:watch": "vitest", + "lint": "eslint src/ --ext .ts,.tsx" + }, + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@testing-library/jest-dom": "^6.1.4", + "@testing-library/react": "^14.1.2", + "@types/react": "^18.2.43", + "@types/react-dom": "^18.2.17", + "@typescript-eslint/eslint-plugin": "^6.14.0", + "@typescript-eslint/parser": "^6.14.0", + "@vitejs/plugin-react": "^4.2.1", + "eslint": "^8.55.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", + "jsdom": "^23.0.1", + "typescript": "^5.3.3", + "vite": "^5.0.8", + "vitest": "^1.1.0" + } +} diff --git a/frontend/public/index.html b/frontend/public/index.html new file mode 100644 index 0000000..f3deb93 --- /dev/null +++ b/frontend/public/index.html @@ -0,0 +1,12 @@ + + + + + + Hello World - React + Vite + + +
+ + + diff --git a/frontend/src/App.test.tsx b/frontend/src/App.test.tsx new file mode 100644 index 0000000..97f24c3 --- /dev/null +++ b/frontend/src/App.test.tsx @@ -0,0 +1,17 @@ +import { render, screen } from '@testing-library/react'; +import { describe, it, expect } from 'vitest'; +import App from './App'; + +describe('App', () => { + it('renders Hello World', () => { + render(); + const heading = screen.getByText('Hello World'); + expect(heading).toBeInTheDocument(); + }); + + it('renders an h1 element', () => { + render(); + const heading = screen.getByRole('heading', { level: 1 }); + expect(heading).toHaveTextContent('Hello World'); + }); +}); diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx new file mode 100644 index 0000000..4811e4c --- /dev/null +++ b/frontend/src/App.tsx @@ -0,0 +1,15 @@ +import React from 'react'; + +/** + * Root application component. + * Renders a simple "Hello World" heading. + */ +function App(): React.JSX.Element { + return ( +
+

Hello World

+
+ ); +} + +export default App; diff --git a/frontend/src/index.css b/frontend/src/index.css new file mode 100644 index 0000000..08a102c --- /dev/null +++ b/frontend/src/index.css @@ -0,0 +1,31 @@ +/* Global styles */ + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + background-color: #f5f5f5; + color: #333; +} + +.app { + text-align: center; +} + +h1 { + font-size: 2.5rem; + font-weight: 700; +} diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx new file mode 100644 index 0000000..5679abf --- /dev/null +++ b/frontend/src/main.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import App from './App'; +import './index.css'; + +/** + * Application entry point. + * Mounts the root React component into the DOM element with id "root". + */ +const rootElement = document.getElementById('root'); + +if (!rootElement) { + throw new Error('Root element not found. Ensure public/index.html contains
.'); +} + +ReactDOM.createRoot(rootElement).render( + + + , +); diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts new file mode 100644 index 0000000..b5d4010 --- /dev/null +++ b/frontend/src/setupTests.ts @@ -0,0 +1,5 @@ +/** + * Test setup file. + * Imports jest-dom matchers so they are available in all test files. + */ +import '@testing-library/jest-dom'; diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json new file mode 100644 index 0000000..3c7f93a --- /dev/null +++ b/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "types": ["vitest/globals"] + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/frontend/tsconfig.node.json b/frontend/tsconfig.node.json new file mode 100644 index 0000000..42872c5 --- /dev/null +++ b/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts new file mode 100644 index 0000000..603c994 --- /dev/null +++ b/frontend/vite.config.ts @@ -0,0 +1,18 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +/// + +export default defineConfig({ + plugins: [react()], + server: { + host: '0.0.0.0', + port: 5173, + }, + test: { + globals: true, + environment: 'jsdom', + setupFiles: './src/setupTests.ts', + css: true, + }, +}); From 734725b9239e0e02a1c7b2db73649bba1aefcd7c Mon Sep 17 00:00:00 2001 From: FORGE Date: Fri, 10 Apr 2026 14:28:53 +0000 Subject: [PATCH 2/4] feat: Implement main App component Run: e33bf8c7-24d6-41ab-a25b-df1c845f66c1 Task: d32a43cb-dbd1-49c0-8287-2b57ee3949ce Agent: builder --- .eslintrc.json | 35 ++++++++++++++ Dockerfile | 22 +++++++++ RUNNING.md | 113 +++++++++++---------------------------------- docker-compose.yml | 18 ++++++++ index.html | 12 +++++ package.json | 34 ++++++++++++++ src/App.module.css | 45 ++++++++++++++++++ src/App.test.tsx | 27 +++++++++++ src/App.tsx | 21 +++++++++ src/index.css | 21 +++++++++ src/main.tsx | 21 +++++++++ src/setupTests.ts | 7 +++ src/vite-env.d.ts | 11 +++++ tsconfig.json | 21 +++++++++ vite.config.ts | 23 +++++++++ 15 files changed, 344 insertions(+), 87 deletions(-) create mode 100644 .eslintrc.json create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 index.html create mode 100644 package.json create mode 100644 src/App.module.css create mode 100644 src/App.test.tsx create mode 100644 src/App.tsx create mode 100644 src/index.css create mode 100644 src/main.tsx create mode 100644 src/setupTests.ts create mode 100644 src/vite-env.d.ts create mode 100644 tsconfig.json create mode 100644 vite.config.ts diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..3dde384 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,35 @@ +{ + "root": true, + "env": { + "browser": true, + "es2020": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "plugins": [ + "@typescript-eslint", + "react", + "react-hooks" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended" + ], + "settings": { + "react": { + "version": "detect" + } + }, + "rules": { + "react/react-in-jsx-scope": "off" + } +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e2c9e1f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Dockerfile for the Hello World React + Vite application. +# +# Uses Node 18 Alpine for a small image footprint. + +FROM node:18-alpine + +WORKDIR /app + +# Copy dependency manifests first for layer caching +COPY package.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the source code +COPY . . + +# Expose the Vite dev server port +EXPOSE 5173 + +# Start the dev server +CMD ["npm", "run", "dev"] diff --git a/RUNNING.md b/RUNNING.md index d44c9e0..339c8d6 100644 --- a/RUNNING.md +++ b/RUNNING.md @@ -1,139 +1,78 @@ -# Hello World React+Vite Application +# Hello World React + Vite Application ## TEAM_BRIEF stack: TypeScript/React+Vite -test_runner: cd frontend && npx vitest run -lint_tool: cd frontend && npx eslint src/ --ext .ts,.tsx +test_runner: npx vitest run +lint_tool: npx eslint src/ --ext .ts,.tsx coverage_tool: none coverage_threshold: 0 coverage_applies: false -## Overview - -A minimal React application built with Vite and TypeScript that displays "Hello World". - ## Prerequisites - **Docker** and **Docker Compose** installed, OR - **Node.js 18+** and **npm** installed locally ---- - -## Docker Setup (Recommended) - -### 1. Build and start the container +## Quick Start (Docker) ```bash -cd frontend +# Build and start the development server docker compose up --build -``` - -### 2. Access the app -Open your browser and navigate to: - -``` -http://localhost:5173 +# The app will be available at http://localhost:5173 ``` -You should see **"Hello World"** displayed on the page. - -### 3. Run tests inside Docker +## Quick Start (Local) ```bash -cd frontend -docker compose run --rm app npm test -``` - -### 4. Run linting inside Docker - -```bash -cd frontend -docker compose run --rm app npm run lint -``` - -### 5. Stop the container - -```bash -cd frontend -docker compose down -``` - ---- - -## Local Setup (Without Docker) - -### 1. Install dependencies - -```bash -cd frontend +# Install dependencies npm install -``` -### 2. Start the development server - -```bash +# Start the development server npm run dev -``` -Open your browser at `http://localhost:5173`. +# The app will be available at http://localhost:5173 +``` -### 3. Run tests +## Running Tests ```bash +# Run the test suite once npm test + +# Run tests in watch mode +npm run test:watch ``` -### 4. Run linting +## Linting ```bash npm run lint ``` -### 5. Build for production +## Building for Production ```bash npm run build -``` - -The production-ready files will be in the `dist/` directory. - -### 6. Preview production build - -```bash npm run preview ``` ---- - ## Project Structure ``` -frontend/ -├── public/ -│ └── index.html # HTML template with
+├── index.html # HTML entry point (Vite convention) ├── src/ +│ ├── main.tsx # React DOM mount point │ ├── App.tsx # Main App component (Hello World) +│ ├── App.module.css # CSS Module for App component │ ├── App.test.tsx # Tests for App component │ ├── index.css # Global styles -│ ├── main.tsx # Application entry point │ ├── setupTests.ts # Test setup (jest-dom matchers) -│ └── vite-env.d.ts # Vite type declarations +│ └── vite-env.d.ts # Vite/CSS module type declarations +├── vite.config.ts # Vite + vitest configuration +├── tsconfig.json # TypeScript configuration +├── package.json # Dependencies and scripts ├── .eslintrc.json # ESLint configuration -├── docker-compose.yml # Docker Compose service definition ├── Dockerfile # Container image definition -├── package.json # Dependencies and scripts -├── tsconfig.json # TypeScript configuration -├── tsconfig.node.json # TypeScript config for Vite -└── vite.config.ts # Vite configuration +└── docker-compose.yml # Docker Compose for local dev ``` - -## Available Scripts - -| Script | Command | Description | -| --------------- | ------------------- | ---------------------------------- | -| `npm run dev` | `vite` | Start development server | -| `npm run build` | `tsc && vite build` | Type-check and build for production| -| `npm run preview`| `vite preview` | Preview production build | -| `npm test` | `vitest run` | Run test suite | -| `npm run lint` | `eslint src/` | Lint source files | diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7437661 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +# Docker Compose configuration for local development. +# +# Runs the Vite dev server with hot-reload via volume mounting. + +version: "3.8" + +services: + app: + build: . + ports: + - "5173:5173" + volumes: + - ./src:/app/src + - ./index.html:/app/index.html + - ./vite.config.ts:/app/vite.config.ts + - ./tsconfig.json:/app/tsconfig.json + environment: + - NODE_ENV=development diff --git a/index.html b/index.html new file mode 100644 index 0000000..d5fc1f0 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + + + + + Hello World + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..71282e5 --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "hello-world-react", + "private": true, + "version": "1.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview", + "test": "vitest run", + "test:watch": "vitest", + "lint": "eslint src/ --ext .ts,.tsx" + }, + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@testing-library/jest-dom": "^6.1.4", + "@testing-library/react": "^14.1.2", + "@types/react": "^18.2.43", + "@types/react-dom": "^18.2.17", + "@typescript-eslint/eslint-plugin": "^6.14.0", + "@typescript-eslint/parser": "^6.14.0", + "@vitejs/plugin-react": "^4.2.1", + "eslint": "^8.55.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", + "jsdom": "^23.0.1", + "typescript": "^5.3.3", + "vite": "^5.0.8", + "vitest": "^1.1.0" + } +} diff --git a/src/App.module.css b/src/App.module.css new file mode 100644 index 0000000..565ac6c --- /dev/null +++ b/src/App.module.css @@ -0,0 +1,45 @@ +/** + * CSS Module for the App component. + * + * Provides a centred, modern layout with gradient text and subtle animations. + */ + +.container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 100vh; + font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; + text-align: center; + padding: 2rem; +} + +.heading { + font-size: 3.5rem; + font-weight: 700; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + -webkit-background-clip: text; + background-clip: text; + -webkit-text-fill-color: transparent; + margin: 0 0 0.5rem; + animation: fadeIn 0.6s ease-out; +} + +.subtitle { + font-size: 1.25rem; + color: #6b7280; + margin: 0; + animation: fadeIn 0.8s ease-out; +} + +@keyframes fadeIn { + from { + opacity: 0; + transform: translateY(10px); + } + to { + opacity: 1; + transform: translateY(0); + } +} diff --git a/src/App.test.tsx b/src/App.test.tsx new file mode 100644 index 0000000..d4a3cf6 --- /dev/null +++ b/src/App.test.tsx @@ -0,0 +1,27 @@ +/** + * Tests for the main App component. + */ +import { render, screen } from '@testing-library/react'; +import { describe, it, expect } from 'vitest'; +import App from './App'; + +describe('App', () => { + it('renders Hello World heading', () => { + render(); + const heading = screen.getByRole('heading', { level: 1 }); + expect(heading).toBeInTheDocument(); + expect(heading).toHaveTextContent('Hello World'); + }); + + it('renders the welcome subtitle', () => { + render(); + const subtitle = screen.getByText(/welcome to your react/i); + expect(subtitle).toBeInTheDocument(); + }); + + it('has the correct CSS module class on the container', () => { + const { container } = render(); + const wrapper = container.firstElementChild; + expect(wrapper).toBeDefined(); + }); +}); diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..00d17d5 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,21 @@ +/** + * Main App component. + * + * Renders a modern-styled "Hello World" heading as the application root. + */ +import React from 'react'; +import styles from './App.module.css'; + +/** + * Top-level application component. + * + * @returns A React element displaying "Hello World" with modern styling. + */ +export default function App(): React.ReactElement { + return ( +
+

Hello World

+

Welcome to your React + Vite application

+
+ ); +} diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..5512726 --- /dev/null +++ b/src/index.css @@ -0,0 +1,21 @@ +/** + * Global styles. + * + * Resets margins/padding and sets a clean base for the application. + */ + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html, +body { + margin: 0; + padding: 0; + background-color: #f9fafb; + color: #111827; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..7460c00 --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,21 @@ +/** + * Application entry point. + * + * Mounts the root component into the DOM element with id "root". + */ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import App from './App'; +import './index.css'; + +const rootElement = document.getElementById('root'); + +if (!rootElement) { + throw new Error('Root element not found. Ensure index.html contains
.'); +} + +ReactDOM.createRoot(rootElement).render( + + + , +); diff --git a/src/setupTests.ts b/src/setupTests.ts new file mode 100644 index 0000000..2558af1 --- /dev/null +++ b/src/setupTests.ts @@ -0,0 +1,7 @@ +/** + * Test setup file. + * + * Imports @testing-library/jest-dom to add custom DOM matchers + * (e.g. toBeInTheDocument) to vitest expectations. + */ +import '@testing-library/jest-dom'; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..825f506 --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1,11 @@ +/// + +/** + * Type declarations for CSS modules. + * + * Allows TypeScript to understand default imports from .module.css files. + */ +declare module '*.module.css' { + const classes: { readonly [key: string]: string }; + export default classes; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e05cb43 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest/globals"] + }, + "include": ["src"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..9f75053 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +/** + * Vite configuration for the React + TypeScript application. + * + * Uses the official React plugin for Fast Refresh and JSX transform. + * The dev server listens on 0.0.0.0:5173 so it is accessible from + * within Docker containers. + */ +export default defineConfig({ + plugins: [react()], + server: { + host: '0.0.0.0', + port: 5173, + }, + test: { + globals: true, + environment: 'jsdom', + setupFiles: './src/setupTests.ts', + css: true, + }, +}); From 3401953f04e2b17a03ef71f516864661ed41ac78 Mon Sep 17 00:00:00 2001 From: FORGE Date: Fri, 10 Apr 2026 14:29:49 +0000 Subject: [PATCH 3/4] feat: Implement entry point and index.html Run: e33bf8c7-24d6-41ab-a25b-df1c845f66c1 Task: c6bd473f-19e9-420e-887f-5236749f7f94 Agent: builder --- .eslintrc.json | 11 +++++------ Dockerfile | 11 ++++++----- RUNNING.md | 49 +++++++++++++++++++++++++--------------------- docker-compose.yml | 8 ++++---- package.json | 1 + src/App.test.tsx | 29 +++++++++++++++------------ src/App.tsx | 15 ++++++-------- src/index.css | 24 ++++++++++++++++------- src/setupTests.ts | 4 ++-- tsconfig.json | 3 ++- vite.config.ts | 16 +++------------ vitest.config.ts | 23 ++++++++++++++++++++++ 12 files changed, 112 insertions(+), 82 deletions(-) create mode 100644 vitest.config.ts diff --git a/.eslintrc.json b/.eslintrc.json index 3dde384..3d50bc3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,8 +2,7 @@ "root": true, "env": { "browser": true, - "es2020": true, - "node": true + "es2020": true }, "parser": "@typescript-eslint/parser", "parserOptions": { @@ -14,15 +13,15 @@ } }, "plugins": [ - "@typescript-eslint", "react", - "react-hooks" + "react-hooks", + "@typescript-eslint" ], "extends": [ "eslint:recommended", - "plugin:@typescript-eslint/recommended", "plugin:react/recommended", - "plugin:react-hooks/recommended" + "plugin:react-hooks/recommended", + "plugin:@typescript-eslint/recommended" ], "settings": { "react": { diff --git a/Dockerfile b/Dockerfile index e2c9e1f..e0a9aea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,23 @@ # Dockerfile for the Hello World React + Vite application. # -# Uses Node 18 Alpine for a small image footprint. +# Uses node:18-alpine as the base image for a lightweight container. +# Installs dependencies and exposes port 5173 for the Vite dev server. -FROM node:18-alpine +FROM node:18-alpine AS base WORKDIR /app -# Copy dependency manifests first for layer caching +# Copy dependency manifests first for better Docker layer caching COPY package.json ./ # Install dependencies RUN npm install -# Copy the rest of the source code +# Copy the rest of the application source COPY . . # Expose the Vite dev server port EXPOSE 5173 -# Start the dev server +# Start the Vite development server CMD ["npm", "run", "dev"] diff --git a/RUNNING.md b/RUNNING.md index 339c8d6..91725cd 100644 --- a/RUNNING.md +++ b/RUNNING.md @@ -1,19 +1,19 @@ -# Hello World React + Vite Application +# Hello World React + Vite App ## TEAM_BRIEF stack: TypeScript/React+Vite test_runner: npx vitest run lint_tool: npx eslint src/ --ext .ts,.tsx -coverage_tool: none -coverage_threshold: 0 -coverage_applies: false +coverage_tool: vitest --coverage +coverage_threshold: 80 +coverage_applies: true ## Prerequisites - **Docker** and **Docker Compose** installed, OR - **Node.js 18+** and **npm** installed locally -## Quick Start (Docker) +## Quick Start with Docker ```bash # Build and start the development server @@ -22,13 +22,13 @@ docker compose up --build # The app will be available at http://localhost:5173 ``` -## Quick Start (Local) +## Local Development (without Docker) ```bash # Install dependencies npm install -# Start the development server +# Start the Vite dev server npm run dev # The app will be available at http://localhost:5173 @@ -37,11 +37,14 @@ npm run dev ## Running Tests ```bash -# Run the test suite once +# Run tests once npm test # Run tests in watch mode npm run test:watch + +# Run tests with coverage +npx vitest run --coverage ``` ## Linting @@ -54,25 +57,27 @@ npm run lint ```bash npm run build + +# Preview the production build npm run preview ``` ## Project Structure ``` -├── index.html # HTML entry point (Vite convention) +. +├── index.html # HTML template with #root mount point ├── src/ -│ ├── main.tsx # React DOM mount point -│ ├── App.tsx # Main App component (Hello World) -│ ├── App.module.css # CSS Module for App component -│ ├── App.test.tsx # Tests for App component -│ ├── index.css # Global styles -│ ├── setupTests.ts # Test setup (jest-dom matchers) -│ └── vite-env.d.ts # Vite/CSS module type declarations -├── vite.config.ts # Vite + vitest configuration -├── tsconfig.json # TypeScript configuration -├── package.json # Dependencies and scripts -├── .eslintrc.json # ESLint configuration -├── Dockerfile # Container image definition -└── docker-compose.yml # Docker Compose for local dev +│ ├── main.tsx # Application entry point +│ ├── App.tsx # Main App component +│ ├── App.test.tsx # Tests for App component +│ ├── index.css # Global styles +│ └── setupTests.ts # Test setup (jest-dom matchers) +├── vite.config.ts # Vite configuration +├── vitest.config.ts # Vitest test configuration +├── tsconfig.json # TypeScript configuration +├── .eslintrc.json # ESLint configuration +├── package.json # Dependencies and scripts +├── Dockerfile # Container definition +└── docker-compose.yml # Docker Compose services ``` diff --git a/docker-compose.yml b/docker-compose.yml index 7437661..69cb619 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,12 @@ # Docker Compose configuration for local development. # -# Runs the Vite dev server with hot-reload via volume mounting. - -version: "3.8" +# Maps port 5173 and mounts source code for live reload. services: app: - build: . + build: + context: . + dockerfile: Dockerfile ports: - "5173:5173" volumes: diff --git a/package.json b/package.json index 71282e5..c94323d 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "version": "1.0.0", "type": "module", + "description": "A minimal Hello World React + Vite + TypeScript application.", "scripts": { "dev": "vite", "build": "tsc && vite build", diff --git a/src/App.test.tsx b/src/App.test.tsx index d4a3cf6..d30a08c 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -1,27 +1,30 @@ /** - * Tests for the main App component. + * Tests for the App component. + * + * Verifies that the main App component renders correctly with + * the expected "Hello World" heading. */ -import { render, screen } from '@testing-library/react'; import { describe, it, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom'; import App from './App'; describe('App', () => { it('renders Hello World heading', () => { render(); - const heading = screen.getByRole('heading', { level: 1 }); - expect(heading).toBeInTheDocument(); - expect(heading).toHaveTextContent('Hello World'); + expect(screen.getByText('Hello World')).toBeInTheDocument(); }); - it('renders the welcome subtitle', () => { - render(); - const subtitle = screen.getByText(/welcome to your react/i); - expect(subtitle).toBeInTheDocument(); + it('renders inside an element with class "app"', () => { + const { container } = render(); + const appDiv = container.querySelector('.app'); + expect(appDiv).toBeInTheDocument(); }); - it('has the correct CSS module class on the container', () => { - const { container } = render(); - const wrapper = container.firstElementChild; - expect(wrapper).toBeDefined(); + it('renders an h1 element', () => { + render(); + const heading = screen.getByRole('heading', { level: 1 }); + expect(heading).toBeInTheDocument(); + expect(heading).toHaveTextContent('Hello World'); }); }); diff --git a/src/App.tsx b/src/App.tsx index 00d17d5..fa13c19 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,21 +1,18 @@ /** * Main App component. * - * Renders a modern-styled "Hello World" heading as the application root. + * Renders the top-level application UI. */ -import React from 'react'; -import styles from './App.module.css'; /** - * Top-level application component. + * Root application component that displays a Hello World heading. * - * @returns A React element displaying "Hello World" with modern styling. + * @returns The rendered App component. */ -export default function App(): React.ReactElement { +export default function App(): JSX.Element { return ( -
-

Hello World

-

Welcome to your React + Vite application

+
+

Hello World

); } diff --git a/src/index.css b/src/index.css index 5512726..211c297 100644 --- a/src/index.css +++ b/src/index.css @@ -1,21 +1,31 @@ /** - * Global styles. + * Global application styles. * - * Resets margins/padding and sets a clean base for the application. + * Provides minimal reset and centres content on the page. */ *, *::before, *::after { box-sizing: border-box; + margin: 0; + padding: 0; } -html, body { - margin: 0; - padding: 0; - background-color: #f9fafb; - color: #111827; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + background-color: #f5f5f5; + color: #333; +} + +.app { + text-align: center; } diff --git a/src/setupTests.ts b/src/setupTests.ts index 2558af1..cbf480c 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -1,7 +1,7 @@ /** * Test setup file. * - * Imports @testing-library/jest-dom to add custom DOM matchers - * (e.g. toBeInTheDocument) to vitest expectations. + * Imports jest-dom matchers so they are available in all test files + * without explicit imports. */ import '@testing-library/jest-dom'; diff --git a/tsconfig.json b/tsconfig.json index e05cb43..adde0b8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, - "types": ["vitest/globals"] + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true }, "include": ["src"] } diff --git a/vite.config.ts b/vite.config.ts index 9f75053..39fc498 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,23 +1,13 @@ +/** + * Vite configuration for the React + TypeScript project. + */ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; -/** - * Vite configuration for the React + TypeScript application. - * - * Uses the official React plugin for Fast Refresh and JSX transform. - * The dev server listens on 0.0.0.0:5173 so it is accessible from - * within Docker containers. - */ export default defineConfig({ plugins: [react()], server: { host: '0.0.0.0', port: 5173, }, - test: { - globals: true, - environment: 'jsdom', - setupFiles: './src/setupTests.ts', - css: true, - }, }); diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..2db1e2e --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,23 @@ +/** + * Vitest configuration. + * + * Configures the test environment to use jsdom for DOM APIs + * and sets up global test utilities. + */ +import { defineConfig } from 'vitest/config'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [react()], + test: { + environment: 'jsdom', + globals: true, + setupFiles: ['./src/setupTests.ts'], + include: ['src/**/*.test.{ts,tsx}'], + coverage: { + provider: 'v8', + include: ['src/**/*.{ts,tsx}'], + exclude: ['src/**/*.test.{ts,tsx}', 'src/setupTests.ts', 'src/main.tsx'], + }, + }, +}); From 8fad5f43dbe7491c5b0108f8dc97fce34263b076 Mon Sep 17 00:00:00 2001 From: FORGE Date: Fri, 10 Apr 2026 14:30:58 +0000 Subject: [PATCH 4/4] feat: Write complete test suite for Hello World app Run: e33bf8c7-24d6-41ab-a25b-df1c845f66c1 Task: 8ae66f1a-ccd0-4432-9563-b1a0d0224f61 Agent: builder --- .eslintrc.json | 8 +++-- Dockerfile | 18 ++++------ RUNNING.md | 85 +++++++++++++++++++++++----------------------- docker-compose.yml | 9 ++--- package.json | 5 +-- src/App.test.tsx | 20 +++++++++++ src/App.tsx | 13 ++++--- src/index.css | 30 ++++++++++------ src/main.tsx | 10 ++---- src/setupTests.ts | 6 ++-- tsconfig.json | 3 +- vite.config.ts | 18 ++++++---- 12 files changed, 124 insertions(+), 101 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3d50bc3..c54e9c7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,11 +2,12 @@ "root": true, "env": { "browser": true, - "es2020": true + "es2020": true, + "node": true }, "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": "latest", + "ecmaVersion": 2020, "sourceType": "module", "ecmaFeatures": { "jsx": true @@ -29,6 +30,7 @@ } }, "rules": { - "react/react-in-jsx-scope": "off" + "react/react-in-jsx-scope": "off", + "react/jsx-uses-react": "off" } } diff --git a/Dockerfile b/Dockerfile index e0a9aea..b83e08d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,19 @@ -# Dockerfile for the Hello World React + Vite application. -# -# Uses node:18-alpine as the base image for a lightweight container. -# Installs dependencies and exposes port 5173 for the Vite dev server. - -FROM node:18-alpine AS base +# Dockerfile for Hello World React+Vite application +FROM node:18-alpine WORKDIR /app -# Copy dependency manifests first for better Docker layer caching +# Copy package manifest first for layer caching COPY package.json ./ # Install dependencies RUN npm install -# Copy the rest of the application source +# Copy the rest of the source code COPY . . -# Expose the Vite dev server port +# Expose Vite dev server port EXPOSE 5173 -# Start the Vite development server -CMD ["npm", "run", "dev"] +# Start the Vite dev server, binding to all interfaces +CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] diff --git a/RUNNING.md b/RUNNING.md index 91725cd..4f3e653 100644 --- a/RUNNING.md +++ b/RUNNING.md @@ -1,4 +1,4 @@ -# Hello World React + Vite App +# Hello World React+Vite App ## TEAM_BRIEF stack: TypeScript/React+Vite @@ -10,74 +10,75 @@ coverage_applies: true ## Prerequisites -- **Docker** and **Docker Compose** installed, OR -- **Node.js 18+** and **npm** installed locally +- **Node.js** >= 18 +- **npm** >= 9 +- **Docker** and **Docker Compose** (optional, for containerised workflow) -## Quick Start with Docker - -```bash -# Build and start the development server -docker compose up --build - -# The app will be available at http://localhost:5173 -``` - -## Local Development (without Docker) +## Local Setup (without Docker) ```bash # Install dependencies npm install -# Start the Vite dev server +# Start the development server npm run dev +# App available at http://localhost:5173 -# The app will be available at http://localhost:5173 -``` - -## Running Tests - -```bash -# Run tests once +# Run tests npm test # Run tests in watch mode npm run test:watch # Run tests with coverage -npx vitest run --coverage -``` - -## Linting +npm run test:coverage -```bash +# Run linter npm run lint + +# Build for production +npm run build ``` -## Building for Production +## Docker Setup ```bash -npm run build +# Build and start the container +docker compose up --build + +# App available at http://localhost:5173 -# Preview the production build -npm run preview +# Run tests inside the container +docker compose exec app npm test + +# Run linter inside the container +docker compose exec app npm run lint + +# Stop and clean up +docker compose down ``` ## Project Structure ``` -. -├── index.html # HTML template with #root mount point +├── index.html # HTML entry point for Vite ├── src/ -│ ├── main.tsx # Application entry point -│ ├── App.tsx # Main App component -│ ├── App.test.tsx # Tests for App component -│ ├── index.css # Global styles -│ └── setupTests.ts # Test setup (jest-dom matchers) -├── vite.config.ts # Vite configuration -├── vitest.config.ts # Vitest test configuration +│ ├── main.tsx # React DOM render entry +│ ├── App.tsx # Main App component (renders Hello World) +│ ├── App.test.tsx # Test suite for App component +│ ├── index.css # Global styles (centred layout) +│ └── setupTests.ts # Vitest setup (jest-dom matchers) +├── package.json # Dependencies and scripts ├── tsconfig.json # TypeScript configuration +├── vite.config.ts # Vite + Vitest configuration ├── .eslintrc.json # ESLint configuration -├── package.json # Dependencies and scripts -├── Dockerfile # Container definition -└── docker-compose.yml # Docker Compose services +├── Dockerfile # Container image definition +└── docker-compose.yml # Docker Compose service definition ``` + +## Acceptance Criteria + +1. `npm test` passes — confirms "Hello World" renders correctly +2. The app displays "Hello World" in a centred `

` element +3. `npm run lint` completes with no errors +4. Styles from `src/index.css` are applied (flexbox centering) diff --git a/docker-compose.yml b/docker-compose.yml index 69cb619..7dd0234 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,13 @@ -# Docker Compose configuration for local development. -# -# Maps port 5173 and mounts source code for live reload. +version: "3.8" services: app: - build: - context: . - dockerfile: Dockerfile + build: . ports: - "5173:5173" volumes: - ./src:/app/src - ./index.html:/app/index.html - ./vite.config.ts:/app/vite.config.ts - - ./tsconfig.json:/app/tsconfig.json environment: - NODE_ENV=development diff --git a/package.json b/package.json index c94323d..04dc39c 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,16 @@ { - "name": "hello-world-react", + "name": "hello-world-app", "private": true, "version": "1.0.0", "type": "module", - "description": "A minimal Hello World React + Vite + TypeScript application.", + "description": "Minimal React Hello World application with TypeScript and Vite", "scripts": { "dev": "vite", "build": "tsc && vite build", "preview": "vite preview", "test": "vitest run", "test:watch": "vitest", + "test:coverage": "vitest run --coverage", "lint": "eslint src/ --ext .ts,.tsx" }, "dependencies": { diff --git a/src/App.test.tsx b/src/App.test.tsx index d30a08c..976027c 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -27,4 +27,24 @@ describe('App', () => { expect(heading).toBeInTheDocument(); expect(heading).toHaveTextContent('Hello World'); }); + + it('h1 is nested inside the .app container', () => { + const { container } = render(); + const appDiv = container.querySelector('.app'); + expect(appDiv).not.toBeNull(); + const h1 = appDiv!.querySelector('h1'); + expect(h1).not.toBeNull(); + expect(h1!.textContent).toBe('Hello World'); + }); + + it('renders exactly one h1 element', () => { + const { container } = render(); + const headings = container.querySelectorAll('h1'); + expect(headings).toHaveLength(1); + }); + + it('does not render unexpected text', () => { + render(); + expect(screen.queryByText('Goodbye World')).not.toBeInTheDocument(); + }); }); diff --git a/src/App.tsx b/src/App.tsx index fa13c19..4d7e802 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,18 +1,17 @@ /** * Main App component. * - * Renders the top-level application UI. + * Renders a centered "Hello World" heading inside a container + * with the class name "app". */ +import './index.css'; -/** - * Root application component that displays a Hello World heading. - * - * @returns The rendered App component. - */ -export default function App(): JSX.Element { +function App(): JSX.Element { return (

Hello World

); } + +export default App; diff --git a/src/index.css b/src/index.css index 211c297..c6674a9 100644 --- a/src/index.css +++ b/src/index.css @@ -1,15 +1,13 @@ /** - * Global application styles. + * Global styles for the Hello World application. * - * Provides minimal reset and centres content on the page. + * Centres content both horizontally and vertically using flexbox. */ -*, -*::before, -*::after { - box-sizing: border-box; +* { margin: 0; padding: 0; + box-sizing: border-box; } body { @@ -18,14 +16,26 @@ body { sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + min-height: 100vh; display: flex; - justify-content: center; align-items: center; - min-height: 100vh; - background-color: #f5f5f5; - color: #333; + justify-content: center; +} + +#root { + width: 100%; } .app { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 100vh; text-align: center; } + +.app h1 { + font-size: 2.5rem; + color: #333; +} diff --git a/src/main.tsx b/src/main.tsx index 7460c00..95c3f34 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,20 +1,14 @@ /** * Application entry point. * - * Mounts the root component into the DOM element with id "root". + * Renders the root App component into the DOM element with id "root". */ import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import './index.css'; -const rootElement = document.getElementById('root'); - -if (!rootElement) { - throw new Error('Root element not found. Ensure index.html contains
.'); -} - -ReactDOM.createRoot(rootElement).render( +ReactDOM.createRoot(document.getElementById('root')!).render( , diff --git a/src/setupTests.ts b/src/setupTests.ts index cbf480c..437b786 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -1,7 +1,7 @@ /** - * Test setup file. + * Test setup file for Vitest. * - * Imports jest-dom matchers so they are available in all test files - * without explicit imports. + * Imports @testing-library/jest-dom to extend Vitest matchers + * with DOM-specific assertions such as toBeInTheDocument(). */ import '@testing-library/jest-dom'; diff --git a/tsconfig.json b/tsconfig.json index adde0b8..e05cb43 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,8 +15,7 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, - "forceConsistentCasingInFileNames": true, - "esModuleInterop": true + "types": ["vitest/globals"] }, "include": ["src"] } diff --git a/vite.config.ts b/vite.config.ts index 39fc498..38f649e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,13 +1,19 @@ -/** - * Vite configuration for the React + TypeScript project. - */ +/// import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +/** + * Vite configuration for the Hello World React application. + * + * Includes the React plugin for JSX transform and Vitest + * configuration for running tests with jsdom. + */ export default defineConfig({ plugins: [react()], - server: { - host: '0.0.0.0', - port: 5173, + test: { + globals: true, + environment: 'jsdom', + setupFiles: ['./src/setupTests.ts'], + css: true, }, });