Skip to main content

Interface: ResultMatchers<R>

Defined in: testing/types.ts:8

Extended Vitest matcher interface for Result types.

Extended by

Type Parameters

R

R = unknown

Methods

toBeErr()

toBeErr<E>(expectedError?): R

Defined in: testing/types.ts:31

Assert that a Result is Err, optionally checking the error.

Type Parameters

E

E

Parameters

expectedError?

E

Returns

R

Example

expect(err('fail')).toBeErr()
expect(err('fail')).toBeErr('fail')
expect(ok(5)).not.toBeErr()

toBeOk()

toBeOk<T>(expectedValue?): R

Defined in: testing/types.ts:19

Assert that a Result is Ok, optionally checking the value.

Type Parameters

T

T

Parameters

expectedValue?

T

Returns

R

Example

expect(ok(5)).toBeOk()
expect(ok(5)).toBeOk(5)
expect(err('fail')).not.toBeOk()

toEqualResult()

toEqualResult<T, E>(expected): R

Defined in: testing/types.ts:42

Deep equality check for Result types.

Type Parameters

T

T

E

E

Parameters

expected

unknown

Returns

R

Example

expect(ok(5)).toEqualResult(ok(5))
expect(err('fail')).toEqualResult(err('fail'))