柴测试套件在完成后阻止其他套件运行

时间:2019-07-29 20:03:40

标签: javascript express chai

所以我下面有这个chai测试套件,它可以运行并通过3个测试。我遇到的问题是,当它在不运行之后又完成了其他测试套件的运行时,当我在此测试套件之前移动其他测试套件时,所有测试套件都将运行。因此,我认为下面的代码阻止了下面的测试套件运行:

suite('POST /api/issues/{project} => object with issue data', function() {

  test('Every field filled in', function(done) {
   chai.request(server)
    .post('/api/issues/issues')
    .send({
      issue_title: 'All filled title',
      issue_text: 'all filled text',
      created_by: 'all filled created by',
      assigned_to: 'all filled assigned to',
      status_text: 'all filled status text'
    })
    .end(function(err, res){
      assert.equal(res.status, 200);

      //fill me in too!
      expect(res.body).to.have.property('_id');
      expect(res.body).to.have.property('issue_title').to.equal('All filled title');
      expect(res.body).to.have.property('issue_text').to.equal('all filled text');
      expect(res.body).to.have.property('created_by').to.equal('all filled created by');
      expect(res.body).to.have.property('assigned_to').to.equal('all filled assigned to');
      expect(res.body).to.have.property('status_text').to.equal('all filled status text');

      testID = res.body._id;
      done();
    });
  });

  test('Required fields filled in', function(done) {
    chai.request(server)
    .post('/api/issues/issues')
    .send({
      issue_title: 'req filled title',
      issue_text: 'req filled text',
      created_by: 'req filled created by',
    })
    .end(function(err, res){
      assert.equal(res.status, 200);

      //fill me in too!
      expect(res.body).to.have.property('_id');
      expect(res.body).to.have.property('issue_title').to.equal('req filled title');
      expect(res.body).to.have.property('issue_text').to.equal('req filled text');
      expect(res.body).to.have.property('created_by').to.equal('req filled created by');
      expect(res.body).to.have.property('assigned_to')
      expect(res.body).to.have.property('status_text')

      done();
    });
  });

  test('Missing required fields', function(done) {
      chai.request(server)
          .post('/api/issues/issues')
          .send({
             assigned_to: 'all filled assigned to',
             status_text: 'all filled status text'         
      })
      .end(function(err, res) {
        expect(res.text).to.equal('Please make sure you have filled in the Issue title, text and created by fields');
        done();
      });
  });

});

0 个答案:

没有答案