Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 231
Aatish Molasi Avatar asked Aug 31 '12 05:08

Aatish Molasi


People also ask

What is describe in JavaScript?

describe() allows you to gather your tests into separate groupings within the same file, even multiple nested levels. Now, nesting is one of the most-maligned features of RSpec, because it's easy to take it too far.

What is a describe block?

Each describe block specifies a larger component or function and contains a set of specifications. A specification is defined by an it block. Each it block functions as a test and is evaluated in its own environment. You can also have nested describe blocks.

What is describe in Jasmine?

Jasmine is a testing framework for JavaScript. Suite is the basic building block of Jasmine framework. The collection of similar type test cases written for a specific file or function is known as one suite. It contains two other blocks, one is “Describe()” and another one is “It()”.

What is describe in mocha?

describe() is simply a way to group our tests in Mocha. We can nest our tests in groups as deep as we deem necessary. describe() takes two arguments, the first is the name of the test group, and the second is a callback function.


2 Answers

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.

like image 50
mmigdol Avatar answered Sep 17 '22 19:09

mmigdol


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

like image 22
yngccc Avatar answered Sep 21 '22 19:09

yngccc