-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Please allow undefined
for actual
when using assertionInstance.assert()
?
#183
Comments
Though I see your point, I'm not keen on reversing the usage of Until then, I see two options: A. If you are just testing property values you can easily use an embedded Assertion. Gives a nice error. new Assertion(this._obj).to.have.property('someSpecialProperty');
this.assert( /* ... */ ); B. Trickery Hackery var prop = this._obj.someSpecialProperty;
this.assert(
prop === 'foo',
'expected foo, got #{act}',
'expected not to get foo',
'foo',
_.inspect(prop) // chai util's inspect always returns string
); |
Unfortunately I am indeed testing some more complicated internal state (promise fulfillment values, which you access via async callbacks). So this won't do the trick. Although, it does seem likely we have other cases in our API where I guess right now
That was my first attempt, but unfortunately the error message then looks like
as opposed to
|
Another way of looking at the problem is that constructing |
I agree, our current implementation isn't optimal for all use cases. Perhaps it is time to start thinking about what the "nextgen" 1. Move it off of the 1a. We would also have to revisit how configurations are stored in order for them to be recognized outside of 2. Change the argument signature to accept a single argument of an object. We can figure out what property names to use later, but this would provide finer grain control for plugin authors of the settings of As both resident ES6 expert and proponent of legacy support, does this seem like a good way to approach this problem? Can we write it in such a way that it will work across the board? |
If I may pitch in on this last message, specifically the part about decorating the A official way to access an exported value of each plugins from within the test suites, like Also an export of the various utils, something like And maybe it's interesting to think about the ideal way to present a custom multi-line error message. Its easy to just pass it in as the regular message but this does clutter reporter 'Spec' or 'List': you'd want a single-line in the spec-tree-structure and a detailed report below (like the way the string-diffs and stack trace show up). I'm not sure if this is possible with the current mocha though: I tried mashing things in the actual / expected values and disabling |
|
Would you be willing to accept a band-aid fix for this in Chai 1.x? Maybe something as silly as a last flag to |
Because of the
getActual
utility, it's impossible to do something where the actual value isundefined
. E.g. if writing a plugin that testssomeSpecialProperty
's value,will give a bad
AssertionError
when used on{ the: "object" }
, which hasactual
equal to the object and prints something like"expected foo, got { the: "object" }"
.The text was updated successfully, but these errors were encountered: