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

toHavePropertiesWithValues matcher function provides confusing message, when assertion fails #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samoshkin
Copy link

Consider following code snippet.

iit('should make related departments available, but not selected', function(){
    expect({ isAvailable: false, isSelected: false }).toHavePropertiesWithValues({ isAvailable: true, isSelected: false });
}

Above I intentionally show erroneous scenario, and got this message, which makes me think that expected object is empty or not present at all.

Expected properties with values {} to be {"isAvailable":true,"isSelected":false}.

What I expect to see is:

Expected properties with values {"isAvailable":false,"isSelected":false} to be {"isAvailable":true,"isSelected":false}.

Looking inside toHavePropertiesWithValues function at https://github.com/uxebu/jasmine-matchers/blob/master/src/toHave.js#L114, I found, that when building message, you remove all falsy properties from the object. Instead, on actual object you should remove only those properties, which are not present on expected one.

Fixed the issue.

@wolframkriesing
Copy link
Member

good find, yeah the shown data doesnt look too informative
additionally in your example i would even only show the difference in this way

Expected properties with values {"isAvailable":false} to be {"isAvailable":true}.

so you don't have to diff it in your head, but see only the things that matter

@wolframkriesing
Copy link
Member

I just tried your example with the current master, and I get

Expected properties with values {"isAvailable":false,"isSelected":false} to be {"isAvailable":true,"isSelected":false}.

did you use the latest that is in master?

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

Successfully merging this pull request may close these issues.

2 participants