In "Moka," # "is of particular importance?

describe('#indexOf()'.... it('#doSth()'); 

In "Moka" has the special meaning of "#"? What does describe and it actually do? Sorry, no document was found for describe and it

+2
mocha
Apr 25 '13 at 5:20
source share
2 answers

describe and it follows a template called BDD , which means "Behavior Driven Development". It just defines an interface that makes you think a little differently about how you write your tests, at least that's what you need. The describe attachment also allows you to group your tests functionally, and the final report has a β€œreadable” feel for it.

Quoting an example from Mocha Docs :

 describe('Array', function(){ describe('#indexOf()', function(){ it('should return -1 when the value is not present', function(){ assert.equal(-1, [1,2,3].indexOf(5)); assert.equal(-1, [1,2,3].indexOf(0)); }) }) }) 

It reads:

Array # indexOf () should return -1 when no value

The first two describe simply setting the scope (description / grouping), and it is the actual test that is being performed. # doesn't really matter. In this case, it just makes the text / report output more like an API doc.

+5
Apr 25 '13 at 5:28
source share

"#" doesn't really matter. This is the standard standard for the # prefix for a method for a particular class. e.g. Array#indexOf() .

I had exactly the same questions on describe() and it() , which did not explain much in the documentation.

Therefore, I wrote a post in the mocha guide . In short:

  • describe() is just for grouping, which you can nest in depth. Also known as test suite.

  • it() is a test case

+4
Feb 08 '14 at 15:18
source share



All Articles