Skip to content

Commit

Permalink
Issue #13: API End to End Tests
Browse files Browse the repository at this point in the history
- Used supertest
- Only tests example
- Doesn't work with watch
  • Loading branch information
codebru committed Oct 27, 2019
1 parent b794227 commit ca379ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Components/Example/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const request = require('supertest')
const app = require('../../index.js');

describe('Post Endpoints', () => {
it('should create a new post', async (done) => {
const res = await request(app)
.get('/example');
expect(res.statusCode).toEqual(200);
console.log(res.text);
expect(res.text).toEqual('SUCCESS');
done();
})
})
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ app.listen(port, () => {
console.log(`App listening on port ${port}`);
});
/* **************************************** */

module.exports = app;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"eslint-plugin-react": "^7.14.2",
"eslint-plugin-security": "^1.4.0",
"jest": "^24.8.0",
"nodemon": "^1.19.1"
"nodemon": "^1.19.1",
"supertest": "^4.0.2"
},
"dependencies": {
"bcrypt": "^3.0.6",
Expand Down

0 comments on commit ca379ee

Please sign in to comment.