Cotton code
17 lines · 773 B · TypeScriptRaw
import type { Reporter, TestModule } from "vitest/node";/** Default reporter counts skips; this adds their environment reasons to CI's summary. */export default class EnvironmentReporter implements Reporter {  onTestRunEnd(modules: ReadonlyArray<TestModule>): void {    const reasons = new Map<string, number>();    for (const module of modules) {      for (const test of module.children.allTests("skipped")) {        const reason = test.meta().environmentSkipReason;        if (typeof reason === "string") reasons.set(reason, (reasons.get(reason) ?? 0) + 1);      }    }    for (const [reason, count] of [...reasons].sort(([a], [b]) => a.localeCompare(b))) {      console.log(`ENV SKIP: ${count} ${count === 1 ? "test" : "tests"} — ${reason}`);    }  }}