Skip to content

Commit 2f46af8

Browse files
committed
fix: remove Chai frames from .deep.equal stack
1 parent d3908a6 commit 2f46af8

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lib/chai/core/assertions.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,10 @@ module.exports = function (chai, _) {
10161016
if (msg) flag(this, 'message', msg);
10171017
var obj = flag(this, 'object');
10181018
if (flag(this, 'deep')) {
1019-
return this.eql(val);
1019+
var prevLockSsfi = flag(this, 'lockSsfi');
1020+
flag(this, 'lockSsfi', true);
1021+
this.eql(val);
1022+
flag(this, 'lockSsfi', prevLockSsfi);
10201023
} else {
10211024
this.assert(
10221025
val === obj

test/expect.js

+16
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,22 @@ describe('expect', function () {
11811181
it('deep.equal(val)', function(){
11821182
expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
11831183
expect({ foo: 'bar' }).not.to.deep.equal({ foo: 'baz' });
1184+
1185+
err(function(){
1186+
expect({foo: 'bar'}).to.deep.equal({foo: 'baz'}, 'blah');
1187+
}, "blah: expected { foo: 'bar' } to deeply equal { foo: 'baz' }");
1188+
1189+
err(function(){
1190+
expect({foo: 'bar'}, 'blah').to.deep.equal({foo: 'baz'});
1191+
}, "blah: expected { foo: 'bar' } to deeply equal { foo: 'baz' }");
1192+
1193+
err(function(){
1194+
expect({foo: 'bar'}).to.not.deep.equal({foo: 'bar'}, 'blah');
1195+
}, "blah: expected { foo: 'bar' } to not deeply equal { foo: 'bar' }");
1196+
1197+
err(function(){
1198+
expect({foo: 'bar'}, 'blah').to.not.deep.equal({foo: 'bar'});
1199+
}, "blah: expected { foo: 'bar' } to not deeply equal { foo: 'bar' }");
11841200
});
11851201

11861202
it('deep.equal(/regexp/)', function(){

test/should.js

+13
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,19 @@ describe('should', function() {
10221022
}, "blah: expected '4' to equal 4");
10231023
});
10241024

1025+
it('deep.equal(val)', function(){
1026+
({ foo: 'bar' }).should.deep.equal({ foo: 'bar' });
1027+
({ foo: 'bar' }).should.not.deep.equal({ foo: 'baz' });
1028+
1029+
err(function(){
1030+
({foo: 'bar'}).should.deep.equal({foo: 'baz'}, 'blah');
1031+
}, "blah: expected { foo: 'bar' } to deeply equal { foo: 'baz' }");
1032+
1033+
err(function(){
1034+
({foo: 'bar'}).should.not.deep.equal({foo: 'bar'}, 'blah');
1035+
}, "blah: expected { foo: 'bar' } to not deeply equal { foo: 'bar' }");
1036+
});
1037+
10251038
it('empty', function(){
10261039
function FakeArgs() {};
10271040
FakeArgs.prototype.length = 0;

0 commit comments

Comments
 (0)