Skip to main content

Vest 6 is ready for testing

Vest 6 is now available under the next tag. This release represents a significant architectural shift, focusing on improved developer experience, predictability, and stronger type safety.

While Vest 5 focused on runtime performance and execution modes, Vest 6 overhauls the API surface to make suite interaction more intuitive and standard-compliant.

You can install it today:

npm install vest@next

Highlights​

The Suite Object​

The most immediate change in Vest 6 is how you interact with a suite. In previous versions, create returned a function that you executed directly.

In Vest 6, create returns a Suite Object. This object provides a unified interface for running, resetting, and inspecting your suite.

import { create, test } from 'vest';

const suite = create(data => {
test('username', 'Username is required', () => {
enforce(data.username).isNotBlank();
});
});

// Run the suite
const result = suite.run(formData);

// Reset state
suite.reset();

Native Promise Support​

Async handling has been simplified. In V6, suite.run() returns a result object that also behaves as a Promise. This removes the need for the promisify utility or specific callback patterns for async suites.

// Await the result directly
const result = await suite.run(data);

if (result.isValid()) {
// ...
}

Integrated Schema Validation​

Vest 6 introduces optional schema validation using n4s (enforce). You can now pass a schema definition to create. This validates the structure of your data before your tests run and, crucially, infers TypeScript types for your suite's data argument.

import { create, test, enforce } from 'vest';

const schema = enforce.shape({
username: enforce.isString(),
age: enforce.isNumber(),
});

// 'data' is now strongly typed based on the schema above
const suite = create(data => {
test('username', 'Must be at least 3 chars', () => {
enforce(data.username).longerThan(2);
});
}, schema);

Standard Schema Compliance​

Vest 6 implements the Standard Schema specification. This allows Vest suites to be used directly by other libraries and tools that support this standard, increasing interoperability across the ecosystem.

const result = await suite.validate(data);

Top-Level Memoization​

The memoization API has been promoted to a top-level export. Instead of being attached to a specific test, memo now wraps a block of logic. This allows you to memoize groups of tests or complex calculations more flexibly.

import { create, test } from 'vest';
import { memo } from 'vest/memo';

create(data => {
memo(() => {
test('heavy-computation', () => {
// ...
});
}, [data.field]);
});

Migrating from V5​

Because V6 introduces changes to the core API (specifically suite.run()), a migration step is required. We have prepared a detailed Upgrade Guide to help you transition your codebase.

The guide also includes a prompt you can use with LLMs to help automate the refactoring process.

Feedback​

This release contains internal architectural changes designed to improve stability and runtime safety. We encourage you to try it out and report any issues on GitHub.