The 'describe' keyword in javascript

So I am a newbie in javascript and i had been going through some one else's code and I found this..

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?

info:
- Its a phonegap application
- We are using the spine.js and jQuery libraries

84177 次浏览

Describe不是 Javascript 的一部分,它是在您使用的库(即 Jasmine)中定义的函数

描述是 茉莉测试框架中的一个函数。它只是描述由“ It”函数枚举的测试用例套件。

也用在 摩卡框架中。

根据 茉莉花文件

describe函数用于对相关规格进行分组,通常每个测试文件在顶层都有一个。String 参数用于命名 specs 集合,并将与 specs 连接以生成 spec 的全名。

“ description”块用于以玩笑的方式将测试分组在一起。 你可浏览以下连结。去 scoping部分,你会明白为什么和如何使用它。

https://jestjs.io/docs/setup-teardown

jest还具有 describe功能。

Https://jestjs.io/docs/api#describename-fn