为什么使用 javascript 测试框架时,没有显式导入 describe,却可以直接使用:?
问题:
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 关键字到底做了什么?
回答:
Describe is a function in the Jasmine testing framework. It simply describes the suite of test cases enumerated by the “it” functions.
Describe 是 Jasmine 测试框架的一个函数。它只是描述了一组用 it 函数枚举的测试用例。
Also used in the mochajs framework.
Describe 也被用在了 mochajs 测试框架中。
Describe is not part of Javascript, it is a function defined in the library you used (namely Jasmine)
Describe 不属于原生 Javascript 的一部分,它是定义在 Jasmine 框架的类库中。