javascript 中的“描述”关键字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12209582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The 'describe' keyword in javascript
提问by Aatish Molasi
So I am a newbie in javascript and i had been going through some one else's code and I found this..
所以我是 javascript 的新手,我一直在浏览其他人的代码,我发现了这个..
describe('deviceready', function() {
it('should report that it fired', function() {
spyOn(app, 'report');
app.deviceready();
expect(app.report).toHaveBeenCalledWith('deviceready');
});
});
What I don't understand is:
What exactly does the describe
keyword do?
我不明白的是:describe
关键字究竟是做什么的?
info:
- Its a phonegapapplication
- We are using the spine.jsand jQuerylibraries
信息:
- 它是一个phonegap应用程序
- 我们正在使用spine.js和jQuery库
回答by mmigdol
回答by yngccc
Describe
is not part of Javascript, it is a function defined in the library you used (namely Jasmine)
Describe
不是 Javascript 的一部分,它是您使用的库中定义的函数(即 Jasmine)
回答by g.y
"A test suite begins with a call to the global Jasmine function describewith two parameters: a string and a function. The stringis a name or titlefor a spec suite - usually what is being tested. The functionis a block of code that implements the suite."
“测试套件以调用全局 Jasmine 函数开始,使用两个参数描述:一个字符串和一个函数。字符串是规范套件的名称或标题- 通常是被测试的内容。该函数是一个 代码块实现套件。”