“#"在摩卡咖啡中是否有特殊含义? [英] Does '#' has special meaning in Mocha?

查看:76
本文介绍了“#"在摩卡咖啡中是否有特殊含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

describe('#indexOf()'....
it('#doSth()');

#"在摩卡咖啡中是否有特殊含义? describeit实际做什么?抱歉,找不到describeit

Does '#' has special meaning in Mocha? What does describe and it actually do? sorry not found document for describe and it

推荐答案

describeit遵循称为BDD的模式,表示行为驱动开发".它只是定义了一个接口,使您对编写测试的方式有所不同,至少应该如此.嵌套describe还可以按功能对测试进行分组,并且生成的报告对此具有可读性".

describe and it follows a pattern called BDD, which means "Behaviour Driven Development". It just defines an interface that makes you think a little different about how you write your tests, at least it should. Nesting of describe also makes it possible to group your tests functionally, and the resulting report has a "readable" feeling to it.

摩卡文档中引用该示例:

Quoting the example from the Mocha docs:

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));
        })
    })
})

它显示为:

不存在该值时,Array#indexOf()应该返回-1

Array#indexOf() should return -1 when the value is not present

前两个描述仅设置(描述/分组)作用域,而it是运行的实际测试. #没有特殊含义.在这种情况下,它只会使输出文本/报告看起来更像API文档.

The first two describes just sets up the (descriptional/grouping) scope, and the it is the actual test that is run. # has no special meaning. In this case, it just makes the output text/report look a little more API-doc like.

这篇关于“#"在摩卡咖啡中是否有特殊含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆