chai-things icon indicating copy to clipboard operation
chai-things copied to clipboard

Asserting on a property that is a specific data type

Open pvienneau opened this issue 8 years ago • 5 comments
trafficstars

Based on chai's property assertion, I am able to do the following for an object:

expect(record).to.have.property('deleted_at').that.is.a('date);

But with chai-things, I get the following error when I try to run the following code:

expect(manyRecords).to.all.have.property('deleted_at').that.is.a('date')

## AssertionError: expected [ Array(1) ] to be a date

Although removing the data type (date) assertion does pass the test, it seems to update the target of the assertion to the provided property, instead resets to the array.

pvienneau avatar Sep 14 '17 15:09 pvienneau

I'm currently having the exact same problem. I think that the problem is that

expect(manyRecords).to.all.have.property('deleted_at')

doesn't return the property, but instead returns this the "manyRecords" array, so our tests fails.

I think that there should be a work around, but it'd be nice to be able to apply this kind of syntax

truca avatar Sep 19 '17 15:09 truca

I just started using chai-things and immediately ran into this issue.

tamias avatar Nov 08 '17 20:11 tamias

+1

OpenByteDev avatar Jul 24 '18 22:07 OpenByteDev

+1

llopess avatar Jun 25 '19 20:06 llopess

I just started using mocha and chai, so I'm not sure if my issue is the same as this one, but I have an array which is a list of English word strings; the following assertion:

allWords.should.all.be.a('string')

gives me the test result:

AssertionError: expected 'AARDVARK' to be a string

brunoparga avatar Nov 04 '19 14:11 brunoparga