0
'use strict';

var should = require('should');

describe('wtf', function () {
    it('compare arrays', function (done) {
        [].should.equal([]);
    });
});

My tests were working fine until I switched from node 10.26 installed from brew to nvm installed version of 10.33.

Here is the error:

AssertionError: expected [] to equal []
Expected :[]
Actual   :[]
chovy
  • 72,281
  • 52
  • 227
  • 295
  • 1
    [`Assertion#equal` function](http://shouldjs.github.io/#assertion-equal) performs simple equality check with `===` operator. But [you can't compare arrays using `===` operator](http://stackoverflow.com/questions/7837456/comparing-two-arrays-in-javascript). So, you should use deep comparison instead (see **Urahara**'s answer). – Leonid Beschastny Mar 19 '15 at 07:54

1 Answers1

3

should( [actual] ).eql( [comapre] ) - deep comparsion


This will pass

it('compare arrays', function (done) {
    var test = [];
    should(test).eql([]);
    done();
});

This will fail

it('compare arrays', function (done) {
    var test = ['t'];
    should(test).eql([]);
    done();
});

Note: Remember to finish the async tests with done()

Piotr Dajlido
  • 1,982
  • 15
  • 28
  • That was it. thank you! -- i figured it had something to do with that but couldn't find the docs. – chovy Mar 20 '15 at 06:48