Closed nkbt closed 9 years ago
Tests? =)
It looks good to me, but I want to see it exercised. =)
Can we fail build on poor coverage, too? That would be handy.
We can. Need to setup Coveralls for that. Easy.
I will add tests today. Need testing tools merged first #15
Add CircleCI to the boilerplate first, and port it in here so we can set up CI integration?
:grey_question:
They are completely independent I reckon. So will do on both in parallel
:+1:
Status update for this and cf-package
?
Had pretty hard 2 days, so picked only low-hanging fruits. Will add CircleCI and basic tests today (after work) so we can merge these.
Sorry to hear that. No worries! =)
Okay, that was actually very quick with CircleCI. I will put repo-specific config instead of Web UI config later. As well as some tests. As part of this PR.
Yay!
Updated with CI, test coverage report and other checks.
Any movement on this?
Not quite happy with tape testing. And also not sure if we need to unit-test code that consists of basically 100% side effects. Maybe some functional tests?
Yes. There should be unit tests for any exported pure functions, and functional tests for api with side effects. Don't mock the filesystem to test a thin wrapper around fs, please. ;)
Clear.
:guitar: :notes:
@ericelliott added tests for find-scaffolds. Found one bug lol =).
Still don't like tape. too much boilerplate...
I could not find any decent examples of how people use tape to write fairly complex and well structured tests. Do you have any by chance?
Do you think we need to test cloverfield? It is kind of side-effects only
Still don't like tape. too much boilerplate...
There is boilerplate in tape? Tests are plain JS functions.
Tests are plain JS functions.
Exactly. So you must build all things around it. Like before/after and so on. Cleaning up spies, restoring stubs.
I am still struggling with mocking dependencies as well. Will try babel-rewire again and pray it will work with coverage (last time I tried - it broke coverage generator).
Yeah that's true, the before/after does add some boilerplate. But it's better than the alternative... having repeated code.
Anything in particular you need a hand with?
Alternatives are beforeEach/afterEach in jasmine and jasmine spies which do all that dirty work for you. Not agitating or arguing though. I'm fine with tape, just ranting.
What would help:
I could not find any decent examples of how people use tape to write fairly complex and well structured tests.
I am still struggling with mocking dependencies
If there are good working solutions that do not break coverage and play nicely with es6/7 - happy not to spend time on that and embrace it in my code.
OK. I always used rewire and sinon for dependency mocking, but I wasn't checking coverage. I can try to take a look at this in the next few days.
Rewire is nice but it is broken for ES6. There is babel-rewire, but when I tried using it on frontend code I could not finish the build/test/coverage. That is most likely due to rewire "adding" more stuff in the code then it was originally there. I've debugged karma/webpack/babel-rewire/isparta and came to conclusion it gets too messy and switched back to inject-loader for webpack, which works perfectly.
But it is not a frontend code anymore here. And node/backend infrastructure is way behind the progress.
This project should have minimal unit tests, and more functional tests. Why? Because it is mostly a tool for working with the filesystem and the network.
My guess is that your logic and your side-effects are too tightly coupled to be tested independently, and that's a code smell.
This post might help clarify: Why I Use Tape Instead of Mocha and So Should You.
"Separation: Logic is thought. Effects are action. Therefore the wise think before acting, and act only when the thinking is done." ~ The Dao of Immutability
Thanks for the article.
find-scaffolds itself could be updated as well, so it would be possible to avoid mocking at all for it. I will look at that as well. Should be quite easy.
find-scaffolds is actually quite testable. So it is now covered. No functional tests.
:+1:
cf can be split more, so I will push CLI side-effects "to the edge" and have those bits of logic pure.
Sounds good. =)
Updated all things
Looking good. Just a test description nitpick before merge. =)
Phew, will fix it asap, riding to work now....
=)
Updated
\o/
Additionally fixed repo url Removed Package Scaffold (moved to https://github.com/cloverfield-tools/cf-package)