Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasmine, turn off default reporter

I have Jasmine with custom reporter

var myReporter = {
  jasmineStarted: function(suiteInfo) {

    console.log('Running suite with ' + suiteInfo.totalSpecsDefined);
  },

  suiteStarted: function(result) {

    console.log('Suite started: ' + result.description + ' whose full description is: ' + result.fullName);
  },

  specStarted: function(result) {

    console.log('Spec started: ' + result.description + ' whose full description is: ' + result.fullName);
  },

  specDone: function(result) {

    console.log('Spec: ' + result.description + ' was ' + result.status);
    for(var i = 0; i < result.failedExpectations.length; i++) {


      console.log('Failure: ' + result.failedExpectations[i].message);
      console.log(result.failedExpectations[i].stack);
    }
  },

  suiteDone: function(result) {

    console.log('Suite: ' + result.description + ' was ' + result.status);
    for(var i = 0; i < result.failedExpectations.length; i++) {

      console.log('AfterAll ' + result.failedExpectations[i].message);
      console.log(result.failedExpectations[i].stack);
    }
  },
  jasmineDone: function() {
    console.log('Finished suite');
  }
};

jasmine.getEnv().addReporter(myReporter);

describe('Top Level suite', function() {
  it('spec', function() {
    expect(1).toBe(1);
  });

  describe('Nested suite', function() {
    it('nested spec', function() {
      expect(true).toBe(true);
    });
  });
});

live: http://jsfiddle.net/wLnmbh88/

Now results show on html and console but I need turn off this in html. How can I show test results only in console? Code example is from jasmine documentation.

like image 874
doyexar Avatar asked Feb 09 '23 15:02

doyexar


1 Answers

No need to remove jasmine-html.js and fiddle with a custom boot.js. Just remove any reporters before adding your reporter of choice:

var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().clearReporters();
jasmine.getEnv().addReporter(new jasmineReporters.TapReporter());
like image 186
Robert Monfera Avatar answered Feb 12 '23 08:02

Robert Monfera