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
Just like suites, you can also exclude individual specs using the xit() function which temporary disables the it() spec and marks the spec as pending.
Excluding Tests / Specs If you want to exclude a specific test, simply use xit() instead of it() . The x means exclude. describe('description', function () { xit('description', function () {}); }); If you want to exclude an entire describe block, use xdescribe() instead of describe() .
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is the title of the spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code.
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');
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With