A constructor that the error will be compared to with instanceof
: error instanceof options.matchConstructor
. If this property is omitted, the error's constructor or
inheritance will not be checked.
A string or RegExp that an error's message will be compared with.
error.message.includes(options.matchMessage)
error.message.match(options.matchMessage)
If this property is omitted, the error message won't be checked at all.
import {assert, type ErrorMatchOptions} from '@augment-vir/assert';
// define the options
const matchOptions: ErrorMatchOptions = {
matchConstructor: Error,
matchMessage: 'some error',
};
assert.throws(
() => {
throw new Error('some error');
},
// use the options
matchOptions,
); // this assertion will pass
A type that represents possible error matching patterns. This is used by the
.throws
andisError
, guards in@augment-vir/assert
as well asitCases
in@augment-vir/test
. Each property is optional, and whichever properties are provided will be checked.