Automattic / Automattic/expect.js

Support comparison of boxed types

Open
#57 2 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

Since threequality obviously doesn't cover boxed natives, I expected `.eql()` to do so, but it doesn't:

```
expect( new String('foo') ).to.eql('foo')
```

---

```
Error: expected { '0': 'f', '1': 'o', '2': 'o' } to sort of equal 'foo'
at Assertion.assert (…proj/node_modules/expect.js/expect.js:99:13)
at Assertion.eql (…proj/node_modules/expect.js/expect.js:214:10)
```

Either `.eql()` should inherently support comparing boxed-types to natives, or we need a form of test that is directly equivalent to `==`. At the moment, all I can do is the following, which is more than a little awkward:

```
expect( (new String('foo')) == 'foo' ).to.be.ok()
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with expect(new String('foo')).to.eql('foo') and inspect node_modules/expect.js/expect.js around Assertion.assert and Assertion.eql, the locations shown in the report. Determine the intended boxed-type comparison behavior, add a regression test, and confirm the assertion handles the reported case.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.