Cleaning up Protractor stack trace Cleaning up Protractor stack trace selenium selenium

Cleaning up Protractor stack trace


As it turns out, if you use any custom reporters, they may introduce new behavior in controlling output of a stack trace. Protractor itself hides pretty much everything, so you won't see any log entries from node_modules or Jasmine.

As you use jasmine-spec-reporter, which provides an option to control a stack trace, it might be the case, that you have set some verbose mode in the options. In the docs for Protractor for some reason it is suggested to use all mode, which basically displays the enitre stack trace.

    onPrepare: function () {    jasmine.getEnv().addReporter(new SpecReporter({      spec: {        displayStacktrace: true      }    }));

If you simply change the option displayStacktrace from all to none, you should get clean results without any stack traces. There are also options summary and specs. You might not notice the difference between them in your example, but if you add a few more specs in your suite, then you'll be able to see the difference:

  1. specs - if spec fails in the process of running tests, you'll see a stack trace for it immediately after a spec failure message
  2. summary - if spec fails in the process of running tests, you'll not see a stack trace for it immediately after a spec failure message, but you'll get a list of all stack traces for failed specs in the end of all tests
  3. all - combines specs and summary - if spec fails in the process of running tests, you'll see a stack trace for it immediately after a spec failure message and you'll get a list of all stack traces for failed specs in the end of all tests
  4. none - stack traces won't be shown anywhere


jasmine-spec-reporter's API has changed.

The new example illustrates a simple option to turn off stack traces:

let SpecReporter = require('jasmine-spec-reporter').SpecReporter;exports.config = {    framework: 'jasmine',    // Your config here...  jasmineNodeOpts: {    print: function () {}  },    onPrepare: function () {        jasmine.getEnv().addReporter(            new SpecReporter({                spec: {                     displayStacktrace: true                }            })        );    }}


For those who are looking for a stable and convenient way to filter out Protractor stacktrace, there is one more option - protractor-beautiful-reporter which would generate a very informative HTML report which also can filter out the stacktrace focusing only on the relevant parts ("smart stack trace" feature).