-
-
Save nwamugo/14a5a8e21beb481b86df93b7a5fb7ee5 to your computer and use it in GitHub Desktop.
| import request from 'supertest'; | |
| import chai from 'chai'; | |
| import chaiAsPromised from 'chai-as-promised'; | |
| import app from '../app'; | |
| chai.use(chaiAsPromised); | |
| const { expect } = chai; | |
| const server = request(app); | |
| const teamMembers = ['Osuh', 'Daniel', 'Edidiong', 'Opara', 'Ennim', 'Favour', 'Ugoji']; | |
| describe('zinnia team', () => { | |
| after(() => { | |
| app.server.close(); | |
| }); | |
| context('team completeness', () => { | |
| it('should be a team of 7', () => { | |
| const size = teamMembers.length; | |
| expect(teamMembers).to.not.be.null; | |
| expect(size).to.equal(7); | |
| )}; | |
| )}; | |
| )}; | |
I love the simplicity of the test, however I need clarification on some concepts
- Why does the first describe statement say 'app', shouldn't it say something like 'Test for Users' or something more descriptive?
- Why did you store
teamMembers.lengthin a variable if it will only be used in that scope?
Is there a reason why
appseems to be tested when, however, the test is onteamMembers?
Eagle Eye! Thank you. I will edit to properly reflect the file I'm in
I love the simplicity of the test, however I need clarification on some concepts
- Why does the first describe statement say 'app', shouldn't it say something like 'Test for Users' or something more descriptive?
- Why did you store
teamMembers.lengthin a variable if it will only be used in that scope?
Thank you. Number 1 question issue has been corrected. And the describe is more apt on what it is testing
For question 2, I adopted a practice of capturing a calculation and saving it in a variable, so that the calculation process will not happen again should I need it somewhere else. In this small example, it may seem over-kill. But its value will shine when scaling.
Thank you for the review. Awesome!
So I don't leave here without a comment, you could replace the let for size with const since the variable is a constant. Eslint would probably flag it too. Great test suite though, well descriptive
So I don't leave here without a comment, you could replace the
letfor size withconstsince the variable is a constant. Eslint would probably flag it too. Great test suite though, well descriptive
Thank you for the feedback. I have now improved the code to reflect the suggestion you made. Improved!
Is there a reason why
appseems to be tested when, however, the test is onteamMembers?