Fix Vitest browser provider setup and test cleanup

- Add @vitest/browser-playwright; use playwright() factory (not string)
- Import page from vitest/browser (not deprecated @vitest/browser/context)
- Add afterEach(cleanup) so each test gets a fresh DOM
- Use oxc transform for JSX instead of esbuild (avoids Vite 8 warning)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-10 19:01:24 +02:00
parent 49c0b2d1f4
commit fcc4f88379
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
4 changed files with 37 additions and 14 deletions

View file

@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
import { render } from "@testing-library/react";
import { page } from "@vitest/browser/context";
import { describe, it, expect, afterEach } from "vitest";
import { render, cleanup } from "@testing-library/react";
import { page } from "vitest/browser";
import { drawElevationChart } from "./elevation-chart-draw";
import type { DrawChartParams } from "./elevation-chart-draw";
@ -46,6 +46,7 @@ function ChartFixture({ params }: { params: DrawChartParams }) {
}
describe("drawElevationChart visual regression", () => {
afterEach(() => cleanup());
it("renders plain color mode", async () => {
render(<ChartFixture params={BASE_PARAMS} />);
await expect(page.getByTestId("chart")).toMatchScreenshot("plain.png");