Skip to content

Latest commit

 

History

History
58 lines (48 loc) · 1.12 KB

no-promise-without-done-fail.md

File metadata and controls

58 lines (48 loc) · 1.12 KB

Disallow using promise without a done.fail (no-promise-without-done-fail).

Make sure that all uses of the promises include a catch(done.fail) within a suite.

Rule details

The following are considered warnings:

describe('A suite', function(done) {
  it('A spec', function() {
    asyncCall().then(done);
  });
});

describe('A suite', function(done) {
  it('A spec', function() {
    asyncCall().then(function() {
      expect(true).toBe(true);
      done();
    });
  });
});

The following patterns are not warnings:

describe('A suite', function(done) {
  it('A spec', function() {
    asyncCall().then(onSuccess, done.fail);
  });
});

describe('A suite', function(done) {
  it('A spec', function() {
    asyncCall().then(done.fail, onError);
  });
});

describe('A suite', function(done) {
  it('A spec', function() {
    asyncCall().then(function() {
      expect(true).toBe(true);
      done();
    }).catch(done.fail);
  });
});

describe('A suite', function(done) {
  it('A spec', function() {
    asyncCall().then(done.fail).catch(function() {
      expect(true).toBe(true);
      done();
    });
  });
});