How can I test a property against a regular expression in chai
? Bonus points: I actually want to test a property of an object returned by a promise using chai-as-promised
(but I guess if I know the non-promise way chai-as-promised
should just work the same way).
My function
function foo() {
return Promise.resolve({ bar: 'baz' });
}
My test (my idea):
// Non-Promise-way
foo().should.match.property('bar', /baz/);
// Promise-way
foo().should.eventually.match.property('bar', /baz/);
(but there is no match.property
)