Answers for "chai request"

1

chai request

test('', done => {
      chai.request(server)
        .post('')
        .set('content-type', 'application/json')
        .send()
        .end((err, response) => {
          if (err) throw err
          assert.equal(response.status, 200);
          assert.equal(, );
          done();        })    });
Posted by: Guest on August-06-2021
0

get chai.request()

it('fails, as expected', function(done) { // <= Pass in done callback
  chai.request('http://localhost:8080')
  .get('/')
  .end(function(err, res) {
    expect(res).to.have.status(123);
    done();                               // <= Call done to signal callback end
  });
});

it('succeeds silently!', function() {   // <= No done callback
  chai.request('http://localhost:8080')
  .get('/')
  .end(function(err, res) {
    expect(res).to.have.status(123);    // <= Test completes before this runs
  });
});
Posted by: Guest on August-26-2020

Browse Popular Code Answers by Language