JavaScript Testing Tactics [video]
blog.testdouble.com
blog.testdouble.com
Week one: this is awesome. It's so clean!
Week two: asynchronous stuff is still an utter pain though. Hey, what's this IcedCoffeeScript...?
Week three: Wow, ICS is great. My tests look like Ruby & rspec now!
Week four: ICS produces unholy Javascript and unintelligible stacktraces. I've lost count of how many hours I've lost trying to figure out which line triggered a test to fail. Let's switch back to CoffeeScript and use async.
Week five: Still fed up not being able to identify which line failed at a glance, and have been bitten more than once by CoffeeScript's indentation causing subtle errors, which is easy to confuse if you do any copypasting within `describe` blocks.
Week six: I'm just going back to straight JavaScript. It's a pain but it does the job.
I've since given up on being able to write tests in Node.js with the same elegance/ease as I can with Ruby & rspec.
I still dig CoffeeScript, but now I only use it for client-side stuff. And as for IcedCoffeeScript, that has found a place in my toolbelt for small scripts, where its speed to write and lack of noise are worth the trade off in maintainability.
Really, a transpiled language isn't much of a stretch.
Edit: Fixed spelling typo.
I use both in the same project. For example, I have a gruntfile written in javascript. It's easy for me to modify it. The rest of my code is in coffeescript. It's easy for me to modify it.
I think this is a really superficial line for you to draw in the sand. Use the best tool for the job. When you build a house, you end up using more than one tool.
Example:
why.stub 'User.find', (userId) ->
{ name: 'Bob' }
https://github.com/lucaspiller/why.jsUse Angular. Every single thing you mentioned there is covered. Except coffeescript, but thats unrelated anyway.
Whats covered ?
Async code : check. ( timeout flush )
Wrapper for XHR : check ($httpBackend ).
DOM abstraction : check ( No DOM Manipulation in controllers! )
fast feedback : check ( karma ) .
Now I like to think of tests as black box and white box. I prefer black box tests because it tells me if the system works from the api or interface, while giving me the freedom to refactor and reimplement without unnecessary drag.
Now for my Shameless plug. If your test suite has lots of edge cases, the test suite takes a long time to run because the same setup logic is being run many times.
I created jasmine-flow to reduce the number of times the setup logic is run by reorganizing the tests into linear flows. https://github.com/btakita/jasmine-flow
I sped up my test suite about 10x (~400 seconds to ~40 seconds) doing this.
I know, it's not 1 second, but since these are black box tests, I know if things work in reality. What is really important for development flow is running individual tests quickly (< 1 second).