I have recently written a few tests like this:
serverRequest.should.have.property("customerId", "abc");
serverRequest.should.have.property("clientId", "123");
serverRequest.should.have.property("scope");
serverRequest.scope.should.deep.equal(["foo", "bar"]);
Those last two lines are sad, but necessary since property does strict equality testing.
I was thinking maybe we should add a third boolean argument to property, that will do deep equality if true? Then it'd be
serverRequest.should.have.property("customerId", "abc");
serverRequest.should.have.property("clientId", "123");
serverRequest.should.have.property("scope", ["foo", "bar"], true);
I guess this is also a case for the properties assertion of #72, heh.
Thoughts?
Is this really necessary? We have setup property to behave differently by changing the subject of the assertion to be the value of whatever path your provide.
serverRequest.should.have.property('scope').to.deep.equal([ 'foo', 'bar' ]);
I have been wanting to add a that chainable, though.
Ohhhhh totally didn't realize that would work :). Good call!!
I just realized that the docs don't cover that difference. Reopening to remind myself to improve doc examples for this in next release.
I know this is an old thread - but is there any equivalent of the above for the assert() API?
Most helpful comment
Is this really necessary? We have setup
propertyto behave differently by changing the subject of the assertion to be the value of whatever path your provide.I have been wanting to add a
thatchainable, though.