Created
August 7, 2018 04:32
-
-
Save alur222/39e05d3896c53d629ce318aae701420a to your computer and use it in GitHub Desktop.
sample mocha, chai and sinon test file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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