import { describe, expect, it, vi } from "vitest"; vi.mock("@hyperframes/parsers/postcss", async (load) => { const real = await load(); return { ...real, parseCss: (css: string) => { if (css.includes("not-a-syntax-error")) throw new Error("ENOENT: no such file, open '/srv/app/.env'"); return real.parseCss(css); }, }; }); const { lintHyperframeHtml } = await import("../hyperframeLinter.js"); const page = (css: string) => `
`; describe("css_parse_error text", () => { it("names the parser's own message for a CSS syntax error", async () => { const { findings } = await lintHyperframeHtml(page(".stage { transform: xPercent: -10; }")); expect(findings.find((f) => f.code === "css_parse_error")?.message).toContain( "Missed semicolon", ); }); it("carries none of the text of any other error thrown while the block is read", async () => { const { findings } = await lintHyperframeHtml(page(".not-a-syntax-error { color: red; }")); const finding = findings.find((f) => f.code === "css_parse_error"); expect(finding?.severity).toBe("error"); expect(finding?.message).not.toMatch(/ENOENT|\/srv\/app|\.env/); }); });