mercredi 7 septembre 2016

Is it good or not have connection between it()?

I am using mocha as test framework in my project.When I write unit test,I prefer to:

describe('cooperation', () => {
  describe('create cooperation', done => {
    it('should create a cooperation between A and B', done => {
      //make a post request to create a cooperation between A and B
      //res.body.should.deepEqual({/*cooperation object*/})
      done();
    });
  });

  describe('get cooperation', done => {
    before(done => {
      //clear any cooperation in database
      //initital cooperation between A and B by fixture tool
      done();
    });

    it('get A's partner', done => {
      //make a get request to get cooperation of A
      //res.body should have B
    });
  });
});

But my workmates prefer to:

describe('cooperation', () => {
  it('should create a cooperation between A and b', done => {
    //make a post request to create a cooperation between A and B
    //res.body.should.deepEqual({/*cooperation object*/})
    done();
  });

  it('get A's partner', done => {
    //make a get request to get cooperation of A
    //res.body should have B
  });
});

I want to know which is better and why?

Aucun commentaire:

Enregistrer un commentaire