Automattic / Automattic/expect.js

RangeError when comparing two objects with eql

Open
#139 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.1k
Forks
207
PR merge metrics
No merged PRs in 30d

Description

I'd like to use `eql` to compare two objects:

```
expect(tokenizeTagText(text)).to.eql([new TextField('only text field')]);
```

But I get this using `mocha`:

```
RangeError: Maximum call stack size exceeded
```

However, if I change the test to use `equal`, they look the same:

```
Error: expected [ { name: 'only text field',
markup: { '0': , length: 1 } } ] to equal [ { name: 'only text field',
markup: { '0': , length: 1 } } ]
```

It seems the `RangeError` comes from expect.js.

It seems the issue is with comparing jQuery elements:

```
it('failing', function () {
expect([ { name: 'only text field',
markup: { '0': $(''), length: 1 } } ]).to.eql([ { name: 'only text field',
markup: { '0': $(''), length: 1 } } ]);
});
it('successful', function () {
expect([ { name: 'only text field',
markup: { '0': '', length: 1 } } ]).to.eql([ { name: 'only text field',
markup: { '0': '', length: 1 } } ]);
});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the two minimal mocha examples in the issue, comparing eql on objects containing jQuery elements with the string-based successful case. Trace the eql comparison until it recurses into the jQuery object; done means the jQuery case no longer raises a maximum call stack error and the existing comparisons still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.