Automattic / Automattic/expect.js

expect({a: 1}).to.have.only.key('a') fails

Open
#66 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

It appears that `have` and `only` cannot be swapped:

``` js
expect({a: 1}).to.only.have.key('a') // this works
expect({a: 1}).to.have.only.key('a') // this doesn't
```

I would expect the second to work, given the documentation, but it fails.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce both assertion chains shown in the issue, then search the JavaScript assertion implementation for how `have`, `only`, and `key` are handled. Done means `expect({a: 1}).to.have.only.key('a')` passes consistently with the documented ordering, while the existing working form remains intact.

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.