Is it possible to send a reason for Jasmine 2 specs skipped with xit or pending()?
Asked Answered
J

2

18

When we find a bug with one of our Protractor Jasmine2 specs, we usually want to skip the test until the bug has been resolved.

I know how to do this with xit or pending(), and JasmineReporters TerminalReporter is doing a nice job of color highlighting and listing pending specs.

However, the pending tests always report No reason given, which implies it is possible to give a reason for the skipped test.

I currently comment the spec with an issue number, but it would be really nice to report the reason the test was disabled and the issue number.

UPDATE

As requested, adding example terminal output ( fdescribe on an example, so reporting most of the suite disabled ):

Versions: Protractor 2.1.0 and Jasmine 2.3.1

Using xit

 Skipped
*      will display the platform if available ...
...
SUCCESS: 85 specs, 0 failures, 1 skipped, 72 disabled in 34.734s.
Pending:

1) will display the platform if available
No reason given

Using pending()

This appears to have started marking it failed, probably related to https://github.com/angular/protractor/issues/1852

Failures:
1) will display the platform if available
Message:
Failed: => marked Pending
Stack:
Error: Failed: => marked Pending

UPDATED: Related feature requests and issues for this functionality

There is currently a feature request to support pending(message) outstanding for Protractor/jasminewd if you want to follow progress :

https://github.com/angular/jasminewd/issues/32 https://github.com/angular/protractor/issues/2454

Journal answered 28/7, 2015 at 23:9 Comment(0)
D
27

Another way would be to call the pend method on the test itself:

xit('Pending test description', function() {
    // test body
}).pend('Reason for being disabled');
Diaphony answered 29/9, 2015 at 8:28 Comment(0)
D
12

pending() receives a single message argument which is actuall a "pending reason":

pending("doesn't work, issue #123")

FYI, here is the initial feature request:

and the official docs:

Defray answered 28/7, 2015 at 23:31 Comment(1)
Thanks, this is what I was looking for, and not currently documented on Jasmine docs. As soon as the Protractor issue with pending() is resolved this should work well.Journal

© 2022 - 2024 — McMap. All rights reserved.