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

Display custom actual in assertion message #44

Open
nwinch opened this issue Apr 30, 2016 · 1 comment
Open

Display custom actual in assertion message #44

nwinch opened this issue Apr 30, 2016 · 1 comment

Comments

@nwinch
Copy link

nwinch commented Apr 30, 2016

Hey @moll! I noticed in the assert function here:

if (!("actual" in opts)) opts.actual = this.actual
if (!("caller" in opts)) opts.caller = assert.caller

var msg = stringify(this.actual) + " must " + (this.negative ? "not " : "")

That this.actual is stringified, though could that be stringify(opts.actual) instead? As this.actual is assigned to opts.actual a couple of lines above anyway if it doesn't already exist.

This would help me pass a more pleasant looking actual for the assertion error message, which I'm doing over at must-jsx.

@moll
Copy link
Owner

moll commented Apr 30, 2016

Hey! Sure, customizing what gets stringified makes sense. I see there's Must.prototype.throw that uses the actual parameter for assigning to the error object but still expecting the original actual (the function that threw an exception) to be stringified. Once I figure out how these two cases can co-exist, I'll make the change ;)

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

2 participants