[英]AssertionError testing arrays with Mocha
I have what I thought was a pretty uncontroversial test to make sure my initial testing setup is working ok. 我有一个我认为是没有争议的测试,可以确保我的初始测试设置正常。
import assert from 'assert';
describe('Test', () => {
it('Arrays', () => {
assert.equal([], []);
});
});
The output of the test is pretty mysterious to me. 测试的输出对我来说很神秘。
> mocha --compilers js:babel-register test/*_test.js
Test
1) Arrays
0 passing (29ms)
1 failing
1) Test Arrays:
AssertionError: [] == []
+ expected - actual
at Context.<anonymous> (basic_test.js:6:12)
npm ERR! Test failed. See above for more details.
Adjectives fail me. 形容词使我失望。 Is there someone who can shed a little light on this.
有没有人可以对此有所了解。
Maybe assert.deepEqual()
is what you are looking for? 也许
assert.deepEqual()
是您要找的东西?
assert.deepEqual([], []);
Alternatively, you could use the should.js library : 另外,您可以使用should.js库 :
require('should');
var a = 'test';
a.should.equal('test'); // "equal" for primitives
var b = [];
b.should.eql([]); // "eql" for data structures
I'd hardly call that an uncontroversial test, in what javascript test framework is []
equal to []
? 在javascript测试框架中
[]
等于[]
,我几乎不会将其称为无争议的测试? Because in vanilla javascript, it definitely isn't. 因为在普通javascript中,绝对不是。
[] == []
false
[] === []
false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.