Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 200
sporkthrower Avatar asked Jul 28 '15 23:07

sporkthrower


People also ask

How can we make individual specs pending in Jasmine?

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.

How do I skip Jasmine test?

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() .

Which of these Jasmine functions defines a single spec that can contain one or more expectations?

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.


2 Answers

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');
like image 197
Delian Mitankin Avatar answered Oct 10 '22 03:10

Delian Mitankin


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:

  • Pending specs overview

and the official docs:

  • jasmine pending docs
like image 23
alecxe Avatar answered Oct 10 '22 04:10

alecxe