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

Update to latest version of expect.js #400

Merged
merged 1 commit into from
Feb 28, 2014

Conversation

jugglinmike
Copy link
Member

In #350, @fb55 and I discovered that the latest version of expect.js (0.3.1) caused false positives in Cheerio's unit test suite. Worse, the generated error was causing Mocha to crash, so TravisCI was unaware that the build was failing. (Actually, you might say this was a good thing because the errors were false positives anyway. But I would argue with you :P)

This problem was introduced when expect.js corrected the parameter order of its eql comparator. This was a legitimate bug fix--it corrected semantics where (functionally speaking) order has no value.

Or it should have no value. Actually, the comparison internal logic has a flaw which makes it non-reflexive. I've submitted a patch against expect.js to remedy this and a separate patch to Node.js (since expect.js's implementation is derived from there).

...but that has little significance to the problem in our test suite--an arguments object should never be considered equivalent to an Array instance. That's why I'm updating the tests to convert all arguments into Arrays before comparison.

As for Mocha: it was crashing while rendering string diffs for the errors generated by expect.js. I've submitted a patch for that, too, but it shouldn't have any bearing on this change.

Commit message:

In version 0.3, expect.js corrected the order of its eql assertion.
This exposed several bugs in Cheerio's unit tests, where aguments
objects were being tested for deep equality with Array instances.

@@ -6,6 +6,7 @@ var vegetables = require('./fixtures').vegetables;
var food = require('./fixtures').food;
var chocolates = require('./fixtures').chocolates;
var inputs = require('./fixtures').inputs;
var toArray = Array.prototype.slice.call.bind(Array.prototype.slice);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first part could be replaced for example with Function.call.bind….

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated

@davidchambers
Copy link
Contributor

LGTM

In version 0.3, expect.js corrected the order of its `eql` assertion.
This exposed several bugs in Cheerio's unit tests, where `aguments`
objects were being tested for deep equality with Array instances.
fb55 added a commit that referenced this pull request Feb 28, 2014
Update to latest version of expect.js
@fb55 fb55 merged commit 3afb883 into cheeriojs:master Feb 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants