expect-match
v1.0.0
Published
Expect Match
Downloads
4
Readme
expect-match
A throwing variant of str.match.
If the string matches the pattern, it acts just like the regular .match.
Otherwise it turns this:
const [, a] = 'foo'.match(/^(\d+)$/);
// TypeError: Cannot read property 'Symbol(Symbol.iterator)' of "foo".matchInto this:
const expectMatch = require('expect-match');
const [, b] = expectMatch('foo', /^(\d+)$/);
// TypeError: String did not match patternFor convenience it also exposes an error code (ENOMATCH).
