Skip to content

Function extend() ​

extend<C>(test: TestAPI<C>, config?: CustomTestConfig): ExtendedTestAPI<C>

Source: test.ts

Extends Vitest's TestAPI with functions from the CustomTestAPI.

Type Parameters ​

C ​

C = object

Parameters ​

test ​

TestAPI<C>

The Vitest test API.

config? ​

CustomTestConfig = {}

The configuration options.

Returns ​

ExtendedTestAPI<C>

The extended test API.

Example ​

You can call this function in one file and export the result.

index.ts
ts
import { test as base } from "vitest";

export const test = extend(base);

Then import and use it across your test files.

isEven.test.ts
ts
import { test } from "./index";

test.simpleCases(isEven, [
	[0, true],
	[1, false],
	[2, true],
]);

With configuration ​

ts
import { test as base } from "vitest";

export const test = extend(base, {
	format: {
		colors: false,
		singleQuotes: true,
		spaceAfterComma: false,
	},
});

Built by Prozilla