The toThrow API is quite weird.
If you pass a string, it matches it anywhere, so 'foo' and /foo/ is the same.
And if you want to strictly match the whole message, you need to do
.toThrow(/^literal message$/)// RegEx with ends.toThrow(newError('literal message'))// The Error class does NOT matter in this case.
If you actually care about the constructor, you have to pass just it.
The
toThrow
API is quite weird.If you pass a string, it matches it anywhere, so
'foo'
and/foo/
is the same.And if you want to strictly match the whole message, you need to do
If you actually care about the constructor, you have to pass just it.
I use
a lot nowadays.