@hitorisensei/jest-assert-with
v1.0.3
Published
Extends jest with toAssertWith matcher that allows you to perform an assert check with a provided assert function.
Readme
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.
