This code is throwing double callback! error followed by:
TypeError: Cannot read property 'status' of undefined at Assertion. (node_modules\chai\lib\chai\core\assertions.js:890:14) at Assertion.ctx.(anonymous function) [as property] (node_modules\chai\lib\chai\utils\addMethod.js:41:25) at Assertion. (node_modules\chai-http\lib\http.js:80:38) at Assertion.ctx.(anonymous function) [as status] (node_modules\chai\lib\chai\utils\addMethod.js:41:25) at tests\unitTest\helloWorld.js:16:37 at Test.Request.callback (node_modules\chai-http\node_modules\superagent\lib\node\index.js:615:12) at ClientRequest. (node_modules\chai-http\node_modules\superagent\lib\node\index.js:567:10) at Socket.socketErrorListener (_http_client.js:269:9) at emitErrorNT (net.js:1269:8)
The error looks random, sometimes it happens sometimes not.
var chai = require('chai')
, chaiHttp = require('chai-http');
chai.use(chaiHttp);
var assert = require('assert');
var expect = chai.expect;
require('should-http');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function(done) {
//assert.equal(-1, [1,2,3].indexOf(4));
//console.log("x")
chai.request('http://192.168.99.100:8080').get('/hello').end(function (err, res) {
expect(res).to.have.status(200);
res.text.should.equal('hello world2');
done();
});
});
});
});
documentation: https://github.com/chaijs/chai-http