Why “should.strictEqual” in should.js doesn't work?
Question
According to should.js Spec this should work:
should.strictEqual(shape.code, code)
but I get:
TypeError: Object #<Object> has no method 'strictEqual'
What am I missing?
Solution
Looks like an error in the documentation. equal
is defined in the script as "strict equal":
/**
* Assert strict equal.
*
* @param {Mixed} val
* @param {String} description
* @api public
*/
equal: function(val, desc){
this.assert(
val.valueOf() === this.obj
, 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "")
, 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "")
, val);
return this;
},
...and strictEqual
does not appear in the script.
OTHER TIPS
Should.js offers .equal() to check for identity (===), and .eql() to check for equality (==).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow