我正在尝试使用 Mocha,这是我从文档中看到的示例:
var assert = require("assert")
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));
})
})
})
大多数示例显示第二个 describe 语句
describe('#indexOf()', function(){
在 #indexOf()
中以 #
开头。这个#
有什么意义?为什么不能简单的写成indexOf
呢?我在哪里可以基本了解 describe 的工作原理?
PS:我查看了 http://visionmedia.github.io/mocha/#interfaces 的文档但无法弄清楚这些是如何出现的以及这些接口(interface)是如何处理的。
谢谢
最佳答案
mocha 的 bdd 语法是在 ruby 的 RSpec 中得到启发的。 ,因此您会找到有关搜索 RSpec 的 mocha 约定的最佳提示,这是一个很好的起点:
特别提到了#
:
For instance, use the Ruby documentation convention of . (or ::) when referring to a class method's name and # when referring to an instance method's name.
关于javascript - Mocha 中的 describe() 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21353562/