Ver Fonte

test(01-01): add sample tests and TypeScript types

- Create src/__tests__/sample.test.tsx to verify Vitest + RTL + jest-dom work
- Create e2e/sample.spec.ts to verify Playwright configuration
- Add vitest/globals to TypeScript types for test globals (describe, it, expect)
tuanchris há 1 semana atrás
pai
commit
803dedaa12

+ 9 - 0
frontend/e2e/sample.spec.ts

@@ -0,0 +1,9 @@
+import { test, expect } from '@playwright/test'
+
+test.describe('Test Infrastructure', () => {
+  test('app loads successfully', async ({ page }) => {
+    await page.goto('/')
+    // App should render without crashing
+    await expect(page.locator('body')).toBeVisible()
+  })
+})

+ 20 - 0
frontend/src/__tests__/sample.test.tsx

@@ -0,0 +1,20 @@
+import { render, screen } from '@testing-library/react'
+import { describe, it, expect } from 'vitest'
+
+// Simple component for testing infrastructure
+function SampleComponent({ message }: { message: string }) {
+  return <div data-testid="sample">{message}</div>
+}
+
+describe('Test Infrastructure', () => {
+  it('renders component with React Testing Library', () => {
+    render(<SampleComponent message="Hello Test" />)
+    expect(screen.getByTestId('sample')).toHaveTextContent('Hello Test')
+  })
+
+  it('has jest-dom matchers available', () => {
+    render(<SampleComponent message="Visible" />)
+    expect(screen.getByTestId('sample')).toBeInTheDocument()
+    expect(screen.getByTestId('sample')).toBeVisible()
+  })
+})

+ 1 - 1
frontend/tsconfig.app.json

@@ -5,7 +5,7 @@
     "useDefineForClassFields": true,
     "lib": ["ES2022", "DOM", "DOM.Iterable"],
     "module": "ESNext",
-    "types": ["vite/client"],
+    "types": ["vite/client", "vitest/globals"],
     "skipLibCheck": true,
 
     /* Bundler mode */