-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
test(animal): unroll animal test loop #3198
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #3198 +/- ##
=======================================
Coverage 99.96% 99.96%
=======================================
Files 2804 2804
Lines 216974 216974
Branches 961 964 +3
=======================================
+ Hits 216900 216904 +4
+ Misses 74 70 -4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way makes the tests more verbose.
It's deliberately more verbose. I feel that test code shouldn't be too "clever". I would argue if the tests were in this format it would have been easier to see what had gone wrong when copy pasting the new test for petName. The compiler / autocomplete would guide you that you needed pet_name not petName for the definition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to agree with @matthewmayer here. Test code is not supposed to be clever. Thinks like the DRY principle should not be applied to make the intend of the test more clear.
In the worst case test case isolation might even break by "clever" helper functions, since these functions are often not tested themself. While this is not the case here, I like to bring awareness of the posibilities for these situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a for loop. I wouldn't call it clever by any means.
A for loop enforces a basic level of consistency across all methods, that a copy paste approach does not.
Ultimately, it doesn't really matter to me.
So I'm fine either way.
Unroll the test loop for animal module
Alternative