I am new to node.I get the error that is Error: connect ECONNREFUSED 127.0.0.1:3100, when I run npm test.
This is my test file.
Test.ts
import * as chai from 'chai';
let chaiHttp = require('chai-http');
import * as assert from 'assertthat';
import * as request from "superagent";
chai.use(chaiHttp);
const expect = chai.expect;
describe('Checking whether the response return status 200', function() {
it('Status OK', function(done) {
return chai.request('https://localhost:3100')
.get('/hello')
.end(function(err, res){
if(err){
done(err);
}
else{
expect(res.body.message).to.equal('hello world');
done();
}
});
});
});
This is my app file
app.ts
import * as express from 'express';
import {Request,Response} from 'express';
const app: express.Express = express();
app.get('/hello',(req:Request,res:Response)=>{
res.json({
message:"hello world"
});
});
app.listen(3100,() =>{
console.log("server listening");
});
export default app;