Skip to content

Instantly share code, notes, and snippets.

@alur222
Created August 7, 2018 04:32
Show Gist options
  • Save alur222/39e05d3896c53d629ce318aae701420a to your computer and use it in GitHub Desktop.
Save alur222/39e05d3896c53d629ce318aae701420a to your computer and use it in GitHub Desktop.
sample mocha, chai and sinon test file
process.env.NODE_ENV = 'test';
const chai = require('chai');
const should = chai.should();
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
const server = require('../../src/app.js');
describe('routes : index', () => {
describe('GET /', () => {
it('should return json', (done) => {
chai.request(server)
.get('/')
.end((err, res) => {
should.not.exist(err);
res.status.should.eql(200);
res.type.should.eql('application/json');
res.body.status.should.equal('success');
res.body.message.should.eql('hello, world!');
done();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment