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

Already on GitHub? Sign in to your account

The error message is the wrong way around #314

Closed
jchannon opened this Issue Jan 8, 2013 · 5 comments

Comments

Projects
None yet
3 participants

jchannon commented Jan 8, 2013

If you have the below test, the error result from Jasmine comes back as Expected undefined to be 'fred'. but it should actually be Expected 'fred' to be undefined.

function returnSecondArg(firstArg, secondArg) {
   return secondArg;
 }

expect(returnSecondArg("only give first arg")).toBe("fred");

joshuacc commented Jan 8, 2013

@jchannon Why do you think that? The expression you are passing to expect evaluates to undefined. It's precisely the same as writing expect(undefined).toBe("fred").

jchannon commented Jan 8, 2013

I understand that you are doing expect(undefined).toBe("fred") but the error message should say Expected 'fred' to be undefined. in terms of english grammar.

What you could do is say Expected: undefined Received: 'fred'"

joshuacc commented Jan 8, 2013

Ah. I understand what you are saying now. However, the English grammar is correct. We don't expect anything of fred. We only expect something to be true of the actual value. In this case, the actual value happens to be undefined.

Note that I'm not speaking about Jasmine's syntax, but about the normal English meaning of the term "expect".

At any rate, I'll resign from this conversation now. :-)

jchannon commented Jan 8, 2013

Yes we expected undefined but we didnt expect undefined to be fred.

I'm English, you're American, who speaks English better? 😄

Contributor

ragaskar commented Jan 8, 2013

This is 'auto-english-ified' by the matcher itself, which is why the phrasing is "to be". I don't anticipate this changing any time soon. "Expected: undefined, Received: 'Fred'" reads better, but doesn't indicate what matcher you used.

@ragaskar ragaskar closed this Jan 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment