-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate testing into the module #6
Comments
I'm just gonna open a discussion on this so that I'm clear what we're actually capable of testing considering the API requires a valid key to get anything valuable returned. I'm all new to this kind of testing so need somewhere to dump some thoughts.
Just a mind dump for now. Thoughts/input appreciated. |
This is kind of a religious question, how to write unit tests.
I simply wouldn't. Our tests should ( at least in my opionion ) test our functionality and not more. E.g.
When you look at this tiny snippet, the functionality of That's it. So I'd go with mocking the dependency and control what this function will return to see if our code is behaving as it should. For mocking dependencies two options come to my mind: Either loading all the dependencies with a dependency injection system. Angular does it this way, and that's why it's so easy to test. You just inject mocked objects and can perfectly check how you code behaves in given cases. Needs some bigger refactoring. Using something like https://www.npmjs.com/package/proxyquire. So changing the Anyways starting writing tests usually also leads to refactoring because testing a function most often shows problems that were not thought through. I hope this explanation helps... And I can give it a shot if you like. :) |
Buy that man a beer! 😄 Thanks for the explanation it's definitely what I needed – I'm gonna have a go at writing these this weekend and will let you know how I get on. |
Haha. Maybe on a conf or something. :) I just recently tried proxyquire and it worked fine. So I'd give it also a try here. |
Have every intention of doing this – been super busy of late. Will take a look ASAP. |
No problem! It's your project. I'm just here to help, if needed. ;) |
Moving this into it's own issue from #2 so it's easier to keep tabs on what needs doing in regards to tests.
lib/normalizeCli.js
testsperfbudget.js
tests.The text was updated successfully, but these errors were encountered: