Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deepEqual does not descriminate by type #1685

Closed
chrisdew opened this issue May 5, 2015 · 5 comments
Closed

deepEqual does not descriminate by type #1685

chrisdew opened this issue May 5, 2015 · 5 comments

Comments

@chrisdew
Copy link

chrisdew commented May 5, 2015

assert.deepEqual({foo:10}, {foo:'10'}); returns true.

@dasilvacontin
Copy link
Contributor

Hi! This isn't related to mocha. However:

That's how node's assert.deepEqual() works, it uses ==. This standalone module made by substack supports strict deep equal via an opts object: https://www.npmjs.com/package/deep-equal.

Or you could use chai. chai has a deep flag, and equal uses ===:

var expect = require('chai').expect
expect({foo:10}).to.deep.equal({foo:'10'}) // AssertionError: expected { foo: 10 } to deeply equal { foo: '10' }

chai docs about deep: http://chaijs.com/api/bdd/#deep-section

@twada
Copy link

twada commented May 5, 2015

FYI: io.js has introduced a deepStrictEqual() method to mirror deepEqual() but performs strict equality checks on primitives since io.js 1.2.0.

see also:

@chrisdew
Copy link
Author

chrisdew commented May 5, 2015

Thanks for all your help.

@dasilvacontin
Copy link
Contributor

Awesome, thanks for sharing @twada!

@Anil-Panghal-Landmark
Copy link

Facing error 'Doc Type is visa | AssertionError: expected undefined to deeply equal 'visa' for following.'
pm.test("Doc Type is visa", function (){
pm.expect(data.documentTypes[5]).to.have.property('documentType');
pm.expect(data.documentType).to.eql('visa');
});
pm.test("scanType is basic", function () {
pm.test(data.documentTypes[5]).to.have.property('scanType');
pm.test(data.documentTypes[5]).to.have.property('supported');
pm.expect(data.scanType).to.contains('basic');
pm.expect(data.supported).to.eql('false');
});
pm.test("scanType is basic_selfie", function () {
pm.test(data.documentTypes[5]).to.have.property('scanType');
pm.test(data.documentTypes[5]).to.have.property('supported');
pm.expect(data.scanType).to.contains('basic_selfie');
pm.expect(data.supported).to.eql('false');
});
pm.test("scanType is enhanced", function () {
pm.test(data.documentTypes[5]).to.have.property('scanType');
pm.test(data.documentTypes[5]).to.have.property('supported');
pm.expect(data.scanType).to.contains('enhanced');
pm.expect(data.supported).to.eql('false');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants