Search code examples
javascriptjasmineprotractorautomated-teststest-suite

Any way to provide reason to a disabled suite in Jasmine


Currently, we can give reason to pending spec using pend() function this way -

xit("pending spec", function(){
    //Skipped spec
}).pend("This is a reason");

Output of the above function would be -

Sample Test: pending spec
This is a reason
Executed 1 of 1 specs (1 PENDING)

Now, how to get the same reason for the disabled suites?

xdescribe('Disabled suite' , function(){
    it('example spec', function(){
        //example
    });
}).pend("This is a reason");

Output of the above disabled suite is -

No reason given

and remains the same even if I use pend() function. Thanks!


Solution

  • The pending message is not implemented on a suite, but you could override the pend method to make it write the message on each spec:

    jasmine.Suite.prototype.pend = function(message){
        this.markedPending = true;
        this.children.forEach(spec => spec.pend(message));
    };
    

    Usage:

    xdescribe('Suite', function() {
    
    
    }).pend("Feature not yet implemented");
    

    Source code for Suite.js:

    https://github.com/jasmine/jasmine/blob/master/src/core/Suite.js#L45