github-actions-demo/tests/test-app.js

25 lines
571 B
JavaScript
Raw Normal View History

2019-01-15 15:40:13 +08:00
const chai = require('chai');
2020-04-25 07:02:34 +08:00
2019-01-15 15:40:13 +08:00
const should = chai.should();
const chaiHttp = require('chai-http');
2020-04-25 07:02:34 +08:00
2019-01-15 15:40:13 +08:00
chai.use(chaiHttp);
const app = require('../index.js');
describe('GET /', () => {
it('should respond with hello world', (done) => {
chai.request(app)
2020-04-25 07:02:34 +08:00
.get('/')
.end((err, res) => {
2019-01-15 15:40:13 +08:00
// there should be no errors
2020-04-25 07:02:34 +08:00
should.not.exist(err);
// there should be a 200 status code
res.status.should.equal(200);
// the response should be JSON
res.type.should.equal('text/plain');
done();
});
2019-01-15 15:40:13 +08:00
});
});