Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declare "pending" specs/tests in jasmine or mocha

I would like to describe specifications that should be in the code, but implementation of them would be added later. In test results I would like to see them neither passed nor failed, but "are waiting" for implementation instead.

I'm interested if it is possible to do out of the box in mocha or jasmine.

Thanks

like image 270
WHITECOLOR Avatar asked Jul 17 '12 08:07

WHITECOLOR


People also ask

How can we make individual specs pending in Jasmine?

Aditionally, there is a pending() function you can call anywhere inside a spec to mark it as pending: it("can be declared by calling 'pending' in the spec body", function() { expect(true). toBe(false); pending(); }); See also the documentation on pending specs in Jasmine 2.0.

What is a pending test in mocha technically?

A pending test in many test framework is test that the runner decided to not run. Sometime it's because the test is flagged to be skipped. Sometime because the test is a just a placeholder for a TODO. For Mocha, the documentation says that a pending test is a test without any callback.


1 Answers

You can declare disabled functions in both mocha and jasmine using xit (instead of it), and xdescribe (instead of describe).

If you want the tests to appear as pending, in mocha you can just leave the second parameter blank in the call to the it() function. For example:

describe('Something', function () {     it('Should be pending')     xit('Should be disabled, i.e not appear on the list') }); 

Update: The behaviour for xit/xdescribe is might change in Mocha if this merge happens: https://github.com/visionmedia/mocha/pull/510

like image 197
Olly Avatar answered Sep 30 '22 18:09

Olly