Automattic / Automattic/expect.js
`expect` return value can't be reused with `.to.have.property`.
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 207
- PR merge metrics
- No merged PRs in 30d
Description
Here's a minimal illustration in [Mocha](http://visionmedia.github.io/mocha/):
```
var expect = require("expect.js");
describe("", function() {
specify("", function() {
var y = expect({ a : 1, b : 2 });
y.to.have.property("a", 1); // This is OK.
y.to.have.property("b", 2); // Mocha outputs "Error: expected 1
// to have a property 'b'".
});
});
```
I'm reusing `expect`'s return value. Why is `expect.js` expecting `1` to have a property `b`?
The issue seems to be with `.to.have.property`, as using other assertions works fine:
```
var x = expect(1);
x.to.be.equal(1); // This is OK.
x.to.not.be.equal(0); // This is OK too.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the minimal Mocha reproduction from the issue and trace the implementation of the `.to.have.property` assertion and its chaining behavior. Done means reusing one `expect` return value allows both property assertions to pass, while the existing scalar equality examples continue to work.
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
- Clearly specified
- Newbie friendliness
- 35/100