Quality Assurance and Testing with Chai - Use the Double Equals to Assert Equality

Hi Team,

I cannot pass tests on ’ Use the Double Equals to Assert Equality’ challenge. Tests results return as:

// running tests
expected 'failed' to equal 'passed'
 == compares object references
// tests completed

My solution is :slight_smile:

 suite('Equality', function() {
    /** 5 - .equal(), .notEqual() **/
    // .equal() compares objects using '=='
    test('#equal, #notEqual', function(){
      //assert.fail( 12, '12', 'numbers are coerced into strings with == ');
      //assert.fail( {value: 1}, {value:1}, '== compares object references');
      //assert.fail( 6 * '2', '12', 'no more hints...');
      //assert.fail( 6 + '2', '12', 'type your error message if you want' );
      assert.equal(12 == '12', 'should be converted');
      assert.equal({ value: 1}, {value: 1}, '== compares object references');
      assert.equal(6 * '2' == '12', 'no more hints...');
      assert.notEqual(6 + '2', '12', 'type your error message if you want');
      
    });

Please help.
Thanks,

1 Like

This fails. Both are not equals.

To compare the contents of two objects, you want the .deepEqual method

https://www.chaijs.com/api/assert/#method_deepequal

Thanks a lot for your help.

Hi guys,

Thanks for help. It’s all resolved now.