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

时间:2015-07-28 23:09:12

标签: javascript testing jasmine protractor jasmine-reporters

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

2 个答案:

答案 0 :(得分:26)

另一种方法是在测试本身上调用pend方法:

xit('Pending test description', function() {
    // test body
}).pend('Reason for being disabled');

答案 1 :(得分: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: