Skip to content

Instantly share code, notes, and snippets.

@iworkforthem
Created January 19, 2017 07:40
Show Gist options
  • Save iworkforthem/f3772f552a13c7f2395d566df6cbb075 to your computer and use it in GitHub Desktop.
Save iworkforthem/f3772f552a13c7f2395d566df6cbb075 to your computer and use it in GitHub Desktop.
unit with mocha & chai.
process.env.NODE_ENV = 'test';
let chai = require('chai');
let chaiHttp = require('chai-http');
let server = require('../app');
let should = chai.should();
chai.use(chaiHttp);
describe('Server', () => {
describe('/GET ', () => {
it('it should load main page', (done) => {
chai.request(server)
.get('/')
.end((err, res) => {
res.should.have.status(200);
done();
});
});
});
describe('/GET ', () => {
it('it should load url /foo/bar', (done) => {
chai.request(server)
.get('/foo/bar')
.end((err, res) => {
res.should.have.status(404);
done();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment