Mocha Chai assert 看起来像是被忽略了
Mocha Chai assert looks like ignored
我有这个小代码:
var expect = require('chai').expect;
describe('simple check', function() {
it('this one shows output', function() {
expect(1).to.equal(1);
});
});
var assert = require('chai').assert;
assert(1 === 1, 'this one looks like ignored');
所以我得到
$ mocha test
simple check
✓ this one shows output
1 passing (5ms)
为什么第二个测试被忽略了?
Mocha 不显示哪些断言已 运行,它仅显示哪些测试已 运行。在这种情况下,您只有一个测试,即 this one shows output
.
所以如果你不做任何断言,它仍然输出同样的东西:
describe('simple check', function() {
it('this one shows output', function() {
});
});
此外,如果文件中任何地方的任何断言有任何错误,它都会显示出来。所以如果你输入 assert(1 === 2, 'one should be two');
它会抛出一个错误并显示给你。
我有这个小代码:
var expect = require('chai').expect;
describe('simple check', function() {
it('this one shows output', function() {
expect(1).to.equal(1);
});
});
var assert = require('chai').assert;
assert(1 === 1, 'this one looks like ignored');
所以我得到
$ mocha test
simple check ✓ this one shows output
1 passing (5ms)
为什么第二个测试被忽略了?
Mocha 不显示哪些断言已 运行,它仅显示哪些测试已 运行。在这种情况下,您只有一个测试,即 this one shows output
.
所以如果你不做任何断言,它仍然输出同样的东西:
describe('simple check', function() {
it('this one shows output', function() {
});
});
此外,如果文件中任何地方的任何断言有任何错误,它都会显示出来。所以如果你输入 assert(1 === 2, 'one should be two');
它会抛出一个错误并显示给你。