<array-like> non-numeric properties with a value of undefined are not ignored
alexjeffburke opened this issue · 4 comments
Hi,
In the case of objects, we ignore properties with a values of undefined during comparisons as follows:
expect(() => {
expect({ a: undefined }, 'to equal', {});
expect({}, 'to equal', { a: undefined });
}, 'not to error');
Attempting to do the same with array-like types using current Unexpected 10.36 does not exhibit this behaviour and instead marks the undefined key missing:
expect(arrx, 'to equal', [])
UnexpectedError:
expected [ nothing: undefined ] to equal []
[
nothing: undefined // should be removed
]
As per discussions in the Unexpected channel this is a bug - filing this issue so we can keep track of it being addressed.
Thanks.
Addressed by unexpectedjs/array-changes#7
Needs to be ported to https://github.com/bruderstein/array-changes-async as well for the async case.
That close and reopen is what I get for trying to reply on my phone. @papandreou glad what’s there so far takes care of one case and I noted that about the -async version - will try to look at that over the next couple of days. Thank you for the reviews etc :)
You're welcome :)
I'm fairly sure that the fix and the associated tests will be almost directly portable to array-changes-async.
@papandreou array-changes-async PR here.
Once we’re happy with both of them and they land, I’ll gladly open a PR for Unexpected core to bump the versions and adjust tests etc.