为什么这个测试在 node.js 上用 should 和 mocha 失败了?
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([]);
});
});
我的测试工作正常,直到我从 brew 安装的节点 10.26 切换到 nvm 安装的 10.33 版本。
这里是错误:
AssertionError: expected [] to equal []
Expected :[]
Actual :[]
should( [actual] ).eql( [comapre] )
- 深度比较
这会过去
it('compare arrays', function (done) {
var test = [];
should(test).eql([]);
done();
});
这会失败
it('compare arrays', function (done) {
var test = ['t'];
should(test).eql([]);
done();
});
Note: Remember to finish the async
tests with done()
'use strict';
var should = require('should');
describe('wtf', function () {
it('compare arrays', function (done) {
[].should.equal([]);
});
});
我的测试工作正常,直到我从 brew 安装的节点 10.26 切换到 nvm 安装的 10.33 版本。
这里是错误:
AssertionError: expected [] to equal []
Expected :[]
Actual :[]
should( [actual] ).eql( [comapre] )
- 深度比较
这会过去
it('compare arrays', function (done) {
var test = [];
should(test).eql([]);
done();
});
这会失败
it('compare arrays', function (done) {
var test = ['t'];
should(test).eql([]);
done();
});
Note: Remember to finish the
async
tests withdone()