jest-assert-type
Adds toAssertWith
method to jest that allows assert check with a provided function.
Test will fail if provided function throws.
Message is created by casing thrown exception to String.
Setup
TypeScript
import the package in you test suite
import '@hitorisensei/jest-assert-with';
this ensures that jest
namespace is properly extended and toAssertWith
is visible to TypeScript
JavaScript
You can use one of two ways
add setupFilesAfterEnv
to jest config
{
"setupFilesAfterEnv": [
"@hitorisensei/jest-assert-with/index.ts"
]
}
or import in you test suite
import '@hitorisensei/jest-assert-with';
Why
Made for use with typescript-is createAssertType
and createAssertEquals
functions.
This allows testing values against TypeScript types.