Skip to content

Latest commit

History

History
36 lines (25 loc) 路 915 Bytes

Vitest.md

File metadata and controls

36 lines (25 loc) 路 915 Bytes

Vitest

Vitest is supported both as a testing framework and a spy library. It will be auto-detected if available.

Setup

In your vitest.config.ts, include console-fail-test/vitest in your setupFiles:

// vitest.config.ts
import { defineConfig } from "vitest/config";

export default defineConfig({
	setupFiles: ["console-fail-test/setup"],
});

Alternately, if you have a setup file already being run first, or you'd like to manually enable this in individual files, you can use the Node API:

// some.test.js
import { describe } from "vitest";

require("console-fail-test").cft();

describe("a test", () => {
	/* ... */
});

Spies

Global console methods will be replaced by vi.fn() spies. You can inspect them at runtime as usual per vitest spies. See vitest's mock functions docs.