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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:24:59  来源:igfitidea点击:

The 'describe' keyword in javascript

javascriptjquerycordovaspine.js

提问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 describekeyword do?

我不明白的是:describe关键字究竟是做什么的?

info:
- Its a phonegapapplication
- We are using the spine.jsand jQuerylibraries

信息:
- 它是一个phonegap应用程序
- 我们正在使用spine.jsjQuery

回答by mmigdol

Describe is a function in the Jasminetesting framework. It simply describes the suite of test cases enumerated by the "it" functions.

Describe 是Jasmine测试框架中的一个函数。它只是描述了由“it”函数枚举的测试用例套件。

Also used in the mochajsframework.

也用在mochajs框架中。

回答by yngccc

Describeis 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 函数开始,使用两个参数描述:一个字符串和一个函数字符串是规范套件的名称或标题- 通常是被测试的内容。该函数是一个 代码块实现套件。”

source: http://jasmine.github.io/2.0/introduction.html

来源:http: //jasmine.github.io/2.0/introduction.html