GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — t3code/scripts/render-metrics.test.ts at main · AndryHTC/t3code

Expand file tree

/

render-metrics.test.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
66 lines (59 loc) · 2.34 KB
/

render-metrics.test.ts

Copy path

File metadata and controls

66 lines (59 loc) · 2.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// @effect-diagnostics nodeBuiltinImport:off - runOnce is a synchronous script, tested on a real temp dir.
import * as NodeFS from "node:fs";
import * as NodeOS from "node:os";
import * as NodePath from "node:path";
import { describe, expect, it, vi } from "vite-plus/test";
import { nondeterministic, renderComparison, runOnce } from "./render-metrics.ts";
const mountReport = { commits: 2, renders: 10, components: { Row: 10 } };
vi.mock("node:child_process", () => ({
spawnSync: (
_command: string,
_args: string[],
options: { env: { T3CODE_RENDER_REPORT_DIR: string } },
) => {
NodeFS.writeFileSync(
NodePath.join(options.env.T3CODE_RENDER_REPORT_DIR, "mount.json"),
JSON.stringify(mountReport),
);
return { status: 0 };
},
}));
describe("runOnce", () => {
it("collects the scenario reports when HOME has no .cache, then removes its report dir", () => {
const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-render-metrics-"));
vi.stubEnv("HOME", home);
vi.stubEnv("TMPDIR", home);
vi.stubEnv("USERPROFILE", home);
vi.stubEnv("TEMP", home);
vi.stubEnv("TMP", home);
try {
expect(runOnce()).toEqual({ mount: mountReport });
expect(NodeFS.readdirSync(home)).toEqual([]);
} finally {
vi.unstubAllEnvs();
NodeFS.rmSync(home, { recursive: true, force: true });
}
});
});
describe("nondeterministic", () => {
it("names only the scenarios whose counts differ between runs", () => {
const stable = { commits: 2, renders: 10, components: { Row: 10 } };
expect(
nondeterministic([
{ mount: stable, type: { commits: 1, renders: 4, components: { Editor: 4 } } },
{ mount: stable, type: { commits: 1, renders: 5, components: { Editor: 5 } } },
]),
).toEqual(["type"]);
});
});
describe("renderComparison", () => {
it("prints per-scenario deltas and the components that moved most", () => {
const output = renderComparison(
{ stream: { commits: 40, renders: 400, components: { Row: 300, Header: 100 } } },
{ stream: { commits: 30, renders: 250, components: { Row: 150, Header: 100 } } },
);
expect(output).toContain("| stream | 40 → 30 (-10, -25%) | 400 → 250 (-150, -37%) |");
expect(output).toContain("| `Row` | 300 → 150 (-150, -50%) |");
expect(output).not.toContain("`Header`");
});
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.