describe('#indexOf()'....
it('#doSth()');
Run Code Online (Sandbox Code Playgroud)
'#'在摩卡中有特殊含义吗?做什么describe和it实际做什么?抱歉没找到文件describe和it
describe并it遵循一种称为BDD"行为驱动开发"的模式.它只是定义了一个界面,让您对编写测试的方式略有不同,至少应该如此.嵌套describe还可以在功能上对测试进行分组,并且生成的报告具有"可读"的感觉.
引用Mocha文档中的示例:
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
})
})
})
Run Code Online (Sandbox Code Playgroud)
它写道:
当值不存在时,Array#indexOf()应返回-1
前两个描述只是设置(描述/分组)范围,而且it是运行的实际测试.#没有特别的意义.在这种情况下,它只是使输出文本/报告看起来更像API-doc.
| 归档时间: |
|
| 查看次数: |
1318 次 |
| 最近记录: |