mjackson / mjackson/expect

Set equality is unexpectedly ordered

Open
#93 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
2.3k
Forks
115
PR merge metrics
No merged PRs in 30d

Description

  it('Compares sets correctly.', (done) => {
    expect(new Set(['a', 'b'])).toEqual(new Set(['b', 'a']));
    done();
  });
      Error: Expected Set (2) {'a', 'b'} to equal Set (2) {'b', 'a'}
      + expected - actual

      -["a","b"]
      +["b","a"]

This is with 1.18.0. I expect set equality to be independent of order; the order of elements is an implementation detail.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Set comparison shown in the issue using expect 1.18.0, then trace the equality logic used by that assertion. Done means the assertion passes when the same Set values are inserted in different orders, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.