Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

render-metrics.test.ts

27 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { nondeterministic, renderComparison } from "./render-metrics.ts";
4​
5describe("nondeterministic", () => {
6 it("names only the scenarios whose counts differ between runs", () => {
7 const stable = { commits: 2, renders: 10, components: { Row: 10 } };
8 expect(
9 nondeterministic([
10 { mount: stable, type: { commits: 1, renders: 4, components: { Editor: 4 } } },
11 { mount: stable, type: { commits: 1, renders: 5, components: { Editor: 5 } } },
12 ]),
13 ).toEqual(["type"]);
14 });
15});
16​
17describe("renderComparison", () => {
18 it("prints per-scenario deltas and the components that moved most", () => {
19 const output = renderComparison(
20 { stream: { commits: 40, renders: 400, components: { Row: 300, Header: 100 } } },
21 { stream: { commits: 30, renders: 250, components: { Row: 150, Header: 100 } } },
22 );
23 expect(output).toContain("| stream | 40 → 30 (-10, -25%) | 400 → 250 (-150, -37%) |");
24 expect(output).toContain("| `Row` | 300 → 150 (-150, -50%) |");
25 expect(output).not.toContain("`Header`");
26 });
27});