protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Calling `pending` in a spec marks the spec as failed.

Open sveneh opened this issue 11 years ago • 32 comments

See the attached testcase

https://gist.github.com/sveneh/9c589d321e6fc31f7460

When I run this in [email protected] using [email protected] I get this:

>protractor pending.conf.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.88.100:60036/wd/hub
Started
F*

Failures:
1) a spec with pending should be pending
  Message:
    Failed: => marked PendingThis is pending.
  Stack:
    Error: Failed: => marked PendingThis is pending.
Pending:

1) a spec with pending should be also pending
  No reason given

2 specs, 1 failure, 1 pending spec
Finished in 0.006 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

running the same spec in pure [email protected]:

>jasmine 
Started
**

Pending:

1) a spec with pending should be pending
  This is pending.


2) a spec with pending should be also pending
  No reason given

2 specs, 0 failures, 2 pending specs
Finished in 0.002 seconds

Protractor should not fail specs that are marked as pending.

sveneh avatar Aug 27 '15 10:08 sveneh

I'm experiencing this too. It would be good to get resolved so I can have accurate reports to delineate tests actually failing and tests being skipped.

cstraynor avatar Sep 08 '15 15:09 cstraynor

Someone please fix this!! In the meantime, to mark as pending without using pending("reason") use xit('some spec description', function (){

theandrewlane avatar Sep 14 '15 16:09 theandrewlane

+1 That's a pretty cool jasmine2 feature and it's a pity that we cannot use it with protractor. Is anyone taking care of this?

lynchblue avatar Sep 15 '15 16:09 lynchblue

+1

ctapobep avatar Sep 20 '15 16:09 ctapobep

See https://github.com/angular/jasminewd/issues/27#issuecomment-144882283

juliemr avatar Oct 02 '15 00:10 juliemr

+1 this is really anoying! I want to be able to put tests to pending with correct messages in log.

bruderol avatar Mar 18 '16 15:03 bruderol

As a workaround I introduced an own pending to use in my protractor tests (overwriting the jasmine pending), maybe that is helpful for somebody else as a workaround:

            // in my protractor onPrepare code:
            var _pending = pending;
            pending = function(pendingMessage) {

                return {

                    it: function(description, itFunction) {
                        var consoleColorYellowStart = '\u001B[33m';
                        var consoleColorYellowEnd = '\u001B[0m';
                        return xit(description + '\n  ' + consoleColorYellowStart + 'Marked as Pending: ' + pendingMessage + consoleColorYellowEnd, itFunction);
                    },

                    describe: function(description, describeFunction) {
                        return describe(description, function() {
                            _pending(pendingMessage);
                            return describeFunction();
                        });
                    },

                    here: function() {
                        return _pending(pendingMessage);
                    }

                };

            };

Usage: pending('my pending comment').describe('my describe block', function() { ... }); or pending('my pending comment').it('my it block', function() { ... }); or (just in case you still need the old pure jasmine pending implementation somewhere else, with all advantages and disadvantages) pending('my pending comment').here();

bruderol avatar Mar 18 '16 16:03 bruderol

+1

akstatic avatar Mar 30 '16 04:03 akstatic

Still experiencing this, meanwhile the workaround works like a charm @bruderol thanks!

lgarest avatar Apr 13 '16 15:04 lgarest

Also feeling some burn here +1

mattc41190 avatar Apr 25 '16 20:04 mattc41190

+1 also happening here. :(

rcbop avatar Apr 29 '16 03:04 rcbop

+1

d-werner avatar Apr 29 '16 14:04 d-werner

+1

ArturKwiatkowski avatar May 05 '16 18:05 ArturKwiatkowski

In the meantime I found out that there is a possibility to set comments on tests ignored with xit and therefore even improved my workaround a little bit:

            // in my protractor onPrepare code:
            var _pending = pending;
            pending = function(pendingMessage) {

                return {

                    it: function(description, itFunction) {
                         var spec = xit(desription, itFunction);
                         spec.pend(pendingMessage);
                         return spec;                        
                    },

                    describe: function(description, describeFunction) {
                        return describe(description, function() {
                            _pending(pendingMessage);
                            return describeFunction();
                        });
                    },

                    here: function() {
                        return _pending(pendingMessage);
                    }

                };

            };

Usage: pending('my pending comment').describe('my describe block', function() { ... }); or pending('my pending comment').it('my it block', function() { ... }); or (just in case you still need the old pure jasmine pending implementation somewhere else, with all advantages and disadvantages) pending('my pending comment').here();

bruderol avatar May 05 '16 18:05 bruderol

also experiencing this, is this issue currently being worked on?

stheikki avatar Jun 02 '16 22:06 stheikki

+1. Also faced with this issue

dverbovyi avatar Jun 08 '16 16:06 dverbovyi

+1 Should be priorize, this is a very usefull feature.

HugoDoyon avatar Jul 12 '16 16:07 HugoDoyon

Closing in favor of https://github.com/angular/jasminewd/issues/32

Note that this is pending a change to Jasmine.

juliemr avatar Jul 14 '16 18:07 juliemr

I extended the jasmine-spec-reporter (https://www.npmjs.com/package/jasmine-spec-reporter)

var SpecReporter = require('jasmine-spec-reporter');
var PendingSpecReporter = SpecReporter;

PendingSpecReporter.prototype.specDone = function (spec) {
  this.metrics.stopSpec(spec);
  var pending = false;
  for(var i = 0; i < spec.failedExpectations.length; i++) {
    if ( spec.failedExpectations[i].message.toLowerCase().indexOf('pending') >= 0) pending = true;
  }
  if (spec.status === 'pending' || pending) {
    this.metrics.pendingSpecs++;
    this.display.pending(spec);
  } else if (spec.status === 'passed') {
    this.metrics.successfulSpecs++;
    this.display.successful(spec);
  } else if (spec.status === 'failed') {
    this.metrics.failedSpecs++;
    this.display.failed(spec);
  }
};

module.exports = PendingSpecReporter;

Specs marked as pending are displayed as pending in the report.

sgibson21 avatar Feb 28 '17 17:02 sgibson21

This hack works for me while we don't have https://github.com/angular/jasminewd/issues/32

// In protractor `onPrepare`
jasmine.Suite.prototype.pend = function (message) {
  this.markedPending = true;
  this.children.forEach(spec => spec.pend(message));
};
xdescribe('Foo', function(){
  // bar
}).pend('reason');

andregs avatar Apr 09 '17 15:04 andregs