Adds Vitest and Playwright testing setup with sample tests
Introduces a unified testing setup using Vitest for unit tests and Playwright for E2E tests. Updates dependencies, adds sample unit and E2E tests, documents test workflow, and codifies testing and code standards in project guidelines. Enables fast, automated test runs and improves code reliability through enforced standards.
This commit is contained in:
27
src/app/components/__tests__/FireCalculatorForm.test.tsx
Normal file
27
src/app/components/__tests__/FireCalculatorForm.test.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import FireCalculatorForm from "../FireCalculatorForm";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
|
||||
// Mocking ResizeObserver because it's not available in jsdom and Recharts uses it
|
||||
class ResizeObserver {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
global.ResizeObserver = ResizeObserver;
|
||||
|
||||
describe("FireCalculatorForm", () => {
|
||||
it("renders the form with default values", () => {
|
||||
render(<FireCalculatorForm />);
|
||||
|
||||
expect(screen.getByText("FIRE Calculator")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText(/Starting Capital/i)).toHaveValue(50000);
|
||||
expect(screen.getByLabelText(/Monthly Savings/i)).toHaveValue(1500);
|
||||
});
|
||||
|
||||
it("renders the Calculate button", () => {
|
||||
render(<FireCalculatorForm />);
|
||||
expect(screen.getByRole("button", { name: /Calculate/i })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user