chovy
chovy

Reputation: 75656

why is this test failing on node.js with should and mocha?

'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   :[]

Upvotes: 0

Views: 127

Answers (1)

Piotr Dajlido
Piotr Dajlido

Reputation: 2030

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()

Upvotes: 3

Related Questions