Skip to content

EMBED-AND-CI-04: Gate a vitest suite on findings

Asserting on runCorpus’s findings inside a test so corpus drift fails the test run.

Builds on: EMBED-AND-CI-01: Run the corpus in-process

A TypeScript program against the library API; inline comments show the resulting values and behavior.

import { expect, test } from "vitest";
import { runCorpus } from "markdown-contract";
import config from "./markdown-contract.config.js";
test("planning corpus has no error findings", () => {
const { findings, exitCode } = runCorpus(config, { cwd: "docs/planning" });
expect(findings.filter((f) => f.level === "error")).toEqual([]);
expect(exitCode).toBe(0);
});
  • runCorpus inside a test
  • Finding.level filtering
  • exitCode assertion