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

Show property name in property that assertion error message #1089

Closed
peteranny opened this issue Nov 17, 2017 · 4 comments
Closed

Show property name in property that assertion error message #1089

peteranny opened this issue Nov 17, 2017 · 4 comments

Comments

@peteranny
Copy link

Given:

const myProps = { myNumber: 'myWrongTypeNumber' }
expect(myProps).to.have.property('myNumber').that.is.a('number')

Which throws:

AssertionError: expected 'myWrongTypeNumber' to be a number

Hope this could be something like

AssertionError: expected 'myWrongTypeNumber' in property 'myNumber' to be a number
@peteranny peteranny changed the title Show property name in property type assertion error message Show property name in property that assertion error message Nov 17, 2017
@sukrosono
Copy link
Contributor

Why it should be on one statement? I would have 2 statement, 1 for the property and 1 for the type.
Let's hear the opinion of the others as well.

@peteranny
Copy link
Author

I thought so too

But now that such API “.that” is provided, doesnt users who use it intend to identify “which” property is wrong or not?
Therefore, I think it is reasonable to include the property name in the assertion when “.that” is used.

@keithamus
Copy link
Member

Hey @peteranny thanks for the issue!

We have plans to improve error messaging, around chai version 5 we should see a completely new system for error messages which should do exactly what you want. I'll close this because its something on the horizon - we just need to get all our ducks in a row first.

@keithamus
Copy link
Member

keithamus commented Nov 20, 2017

Oh and - #457 is our roadmap issue. You can track progress on v5 there.

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

3 participants