jeudi 5 octobre 2017

jasmine custom reporter does not respecting xdescribe & fdescribe

We follow the jasmine guidelines and use xdescribe to disable specific test temporary and force single tests while developing and debugging issues.

on the other hand we have code which have to run before every test. I don´t want to keep redundant code in over 200 test files. In my opinion nested describe with beforeEach is not a good approach.

Jasmine is offering custom reporters which are already in place for many other use cases. Sadly suiteStarted is called on xdescribe and on describe in case of fdescribe is used as well. Example code below.

onPrepare: function() {
   jasmine.getEnv().addReporter(new function () {
       this.suiteStarted = function (spec) {
            console.log(spec);
    };
});

fdescribe('will be forced', function(){
   it('step', function() {
});

xdescribe('should be skipped', function(){
   it('open home page', function() {
});

describe('should be skipped', function(){
   it('step', function() {
});

output:

{ id: 'suite1',
  description: 'will be forced',
  fullName: 'will be forced',
  failedExpectations: [] }
{ id: 'suite2',
  description: 'Ashould be skipped',
  fullName: 'should be skipped',
  failedExpectations: [] }
{ id: 'suite3',
  description: 'should be skipped',
  fullName: 'should be skipped',
  failedExpectations: [] }

Aucun commentaire:

Enregistrer un commentaire