I've tried to make a deepEqual assertion with should.js (the latest version) and have not had any success. I can get things to work with equal
but not with deepEqual
. In fact I am seeing that there is no deepEqual
method.
Here's what I've tried:
> require('should')
{...}
> > var x = Number(8)
undefined
> x.should.equal(8)
{ obj: 8 }
> x.should.equal(9)
AssertionError: expected 8 to equal 9
at ....
> x.should.deepEqual(8)
TypeError: Object #<Object> has no method 'deepEqual'
Fair enough. Now looking into should
, I see it is a getter:
> Object.getOwnPropertyDescriptor(Object.prototype, 'should')
{ get: [Function],
set: [Function],
enumerable: false,
configurable: true }
Since it is a getter, how to I examine its keys? This almost works:
> Object.keys(Object.prototype.should)
[ 'obj' ]
But then I see
> Object.getOwnPropertyDescriptor(should.obj)
{ value: undefined,
writable: false,
enumerable: false,
configurable: false }
So I'm rather stuck at this point. I would just like to see what things can follow should
.
I did read the docs and it says that should.js
literally extends node's assert module, but node's assert does allow deepEqual
.
> assert = require('assert')
> assert.deepEqual
[Function: deepEqual]
The should docs don't even mention deepEqual
at all, which really has me confused. To make things even more confusing, I do see a deepEqual
when I enter should
on the node REPL. But it is buried in an ok
element, as far as I can tell.
TL;DR: How do I call assertEqual
or its equivalent from should
?
I've tried to make a deepEqual assertion with should.js (the latest version) and have not had any success. I can get things to work with equal
but not with deepEqual
. In fact I am seeing that there is no deepEqual
method.
Here's what I've tried:
> require('should')
{...}
> > var x = Number(8)
undefined
> x.should.equal(8)
{ obj: 8 }
> x.should.equal(9)
AssertionError: expected 8 to equal 9
at ....
> x.should.deepEqual(8)
TypeError: Object #<Object> has no method 'deepEqual'
Fair enough. Now looking into should
, I see it is a getter:
> Object.getOwnPropertyDescriptor(Object.prototype, 'should')
{ get: [Function],
set: [Function],
enumerable: false,
configurable: true }
Since it is a getter, how to I examine its keys? This almost works:
> Object.keys(Object.prototype.should)
[ 'obj' ]
But then I see
> Object.getOwnPropertyDescriptor(should.obj)
{ value: undefined,
writable: false,
enumerable: false,
configurable: false }
So I'm rather stuck at this point. I would just like to see what things can follow should
.
I did read the docs and it says that should.js
literally extends node's assert module, but node's assert does allow deepEqual
.
> assert = require('assert')
> assert.deepEqual
[Function: deepEqual]
The should docs don't even mention deepEqual
at all, which really has me confused. To make things even more confusing, I do see a deepEqual
when I enter should
on the node REPL. But it is buried in an ok
element, as far as I can tell.
TL;DR: How do I call assertEqual
or its equivalent from should
?
1 Answer
Reset to default 15I think you should (pun intended) use the eql
method.
https://github./visionmedia/should.js/#eql
({ foo: 'bar' }).should.eql({ foo: 'bar' })