-
-
Notifications
You must be signed in to change notification settings - Fork 700
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
negated property(name, value) assertion #16
Comments
You will notice the error type when this occurs is not an AssertionError, but a regular Error.. L569. It didn't fail because the assertion failed, it failed because the pretenses of the test were insufficiently prepared and therefor outside of chai's ability to pass judgement. As such, I think the appropriate response is to inform the developer of this. Make sense? Thoughts? |
As I see it, there are two equivalent interpretations of
In neither case is chai unprepared to pass judgement as I see it. Maybe you can elaborate on your thinking? |
Very logical arguments. I applaud your use of De Morgan's law! However, the point of the expect('asd').to.not.have.property('foo', 3);
// 1. "I expect asd to not have the property `foo`, and assert that `foo` should equal 3."
// 2. "I expect asd to not have the property `foo`, and assert that `foo` should not equal 3."
// 3. "I expect asd to have the property `foo`, and assert that `foo` should not equal 3."
|
Actually, #2 is not my approach. My approach is: "I expect that either asd does not have property I believe it is least surprising if the assertion "X should Y" succeeds exactly when the assertion "X should not Y" fails, and vice versa. It's simple, predictable, and how negation works in every assertion library I've seen prior to chai. Though now I've looked and it seems should.js and expect.js both have this quirk as well, so perhaps I'm on the losing side in that regard. As for the third interpretation, I would write such an assertion as |
I'm not sure I like 'either' as an approach in this testing scenario. I don't like that a single assertion could pass for two separate scenarios. Especially where there is multiple interpretations of how the language chain should operate, Its better to throw and force the user be more succinct. A hazard of working with language chaining assertion libraries... but perhaps it's a curtesy in the long run. |
I am going to close this issue. At this time, compatibility with similar libraries (expect/should) makes chai more accessible to new users wanting to migrate. As far as the debate of logics go, shall we call it a stalemate for the time being? ;) |
👍 I'm struggling to write a Ideally, I'm attempting to compose this assertion from |
I would expect a negated assertion to pass if and only if it would fail if not negated. But this is not true of the
property(name, value)
assertion:I realize the test verify the existing behavior, but is there any chance it could change?
The text was updated successfully, but these errors were encountered: