Thursday, September 14, 2023
HomeJavascriptUtilizing 'it.skip()' in Mocha - Understanding JS

Utilizing ‘it.skip()’ in Mocha – Understanding JS


Aug 4, 2023.

The it.skip() feature informs Mocha to avoid that specific examination.
As an example, in the adhering to code, Mocha will certainly not run test2

 it(' test1',  feature()  {} );.
it.skip(' test2',  feature()  {} );.
it(' test3',  feature()  {} );

Running Mocha on the above data will certainly generate the list below outcome.
Due to the fact that test2 was avoided, Mocha will certainly suggest that there’s 1 “pending” examination – “pending” examinations are one more word for avoided examinations.

$ mocha./ test.js.


✓ test1.
- test2.
✓ test3.

 2 death ( 4 ms).
 1 pending.

$ 

We advise making use of avoid() as opposed to commenting out examinations.
The advantage of making use of avoid() is that Mocha can inform you when there are examinations avoided through the “pending” outcome, whereas Mocha can not inform you when there are commented out examinations.

With define()

avoid() is the inverse of just(): avoid() avoids the significant examination, just() avoids every examination aside from the significant examination.
Like just(), you can utilize avoid() with define() to avoid an entire block of examinations as complies with.


describe.skip(' collection',  feature()  {
it(' test1',  feature()  {} );.
it(' test2',  feature()  {} );.
} );.

it(' test3',  feature()  {} );

The over manuscript creates the list below outcome.

$ mocha./ test.js.


✓ test3.
collection.
- test1.
- test2.


 1 death ( 3 ms).
 2 pending.

$ 

Extra Mocha Tutorials

RELATED ARTICLES

Most Popular

Recent Comments