javascripttestingjasmineprotractorjasmine-reporters

Print only jasmine focused tests


It is difficult to describe how useful and convenient the "Focused Specs" feature of jasmine >=2.1 is. By using fdescribe and/or fit we can run only the specified tests without modifying the protractor config.

The only problem is the output on the console. It prints out every single spec matching the pattern in the protractor configuration.

First, the focused specs test results are printed. This information is useful:

Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
Started
open Case Screen
  should display correct url ...
 Passed
.  should display summary description ... 
 Passed

Then, there is a huge output containing "Disabled" tests (~20 seconds to scroll down):

click the Back button after switching environment
  should redirect to Queue in previous environment ...
 Disabled
1 of 1 passed (0 skipped, 1 disabled).
...
'You have been logged out.' alert message
  should show a alert message after closing all sessions in another browser window ...
 Disabled
1 of 1 passed (0 skipped, 1 disabled).
SUCCESS: 202 specs, 0 failures, 0 skipped, 199 disabled in 12.89s.

In other words, there were only 3 specs out of 202 executed, but all 202 were printed on the console, 199 of them were disabled.

Is there a way to avoid having disabled specs being written on the console while having the verbose information about focused tests?


Note that we are using TerminalReporter from jasmine-reporters:

jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({
    verbosity: 3,
    color: true,
    showStack: true
}));

Setting the verbosity to < 3 helps to solve the problem with disabled tests, but in this case, we are not getting any information about which tests were focused:

Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
Started
...SUCCESS: 202 specs, 0 failures, 0 skipped, 199 disabled in 12.225s.

202 specs, 0 failures

Solution

  • For those with the same problem in the future - decided to use a different terminal reporter instead - jasmine-spec-reporter - it is quite configurable and provides a more precise and better formatted output (see these awesome checkboxes, for example):

    enter image description here

    Note that it still reports maximum information about the executed tests. Exactly what we needed in this case.