The 'describe' keyword in javascript

2019-03-08 13:11发布

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

3条回答
孤傲高冷的网名
2楼-- · 2019-03-08 13:19

Describe is not part of Javascript, it is a function defined in the library you used (namely Jasmine)

查看更多
放我归山
3楼-- · 2019-03-08 13:33

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

Also used in the mochajs framework.

查看更多
迷人小祖宗
4楼-- · 2019-03-08 13:42

"A test suite begins with a call to the global Jasmine function describe with two parameters: a string and a function. The string is a name or title for a spec suite - usually what is being tested. The function is a block of code that implements the suite."

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

查看更多
登录 后发表回答