Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asserting on a property that is a specific data type #60

Open
pvienneau opened this issue Sep 14, 2017 · 5 comments
Open

Asserting on a property that is a specific data type #60

pvienneau opened this issue Sep 14, 2017 · 5 comments

Comments

@pvienneau
Copy link

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.

@truca
Copy link

truca commented Sep 19, 2017

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

@tamias
Copy link

tamias commented Nov 8, 2017

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

@OpenByteDev
Copy link

+1

1 similar comment
@llopess
Copy link

llopess commented Jun 25, 2019

+1

@brunoparga
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants