开发者

Testing server-side/client-side coffeescript code

开发者 https://www.devze.com 2023-03-30 06:19 出处:网络
What do you use to test Cof开发者_如何学JAVAeeScript in the browser and in the server (node.js)?

What do you use to test Cof开发者_如何学JAVAeeScript in the browser and in the server (node.js)?

Thanks


I use QUnit to test my CoffeeScript code in both a browser and via commandline; you can use node-qunit to test on the server. There are other solutions out there, but QUnit fits my needs pretty well and can be quite elegantly utilized from CoffeeScript:

module 'MyModule'

test 'MyModule.someFunction', ->
    ok someValue
    strictEqual anotherValue, 323

QUnit, additionally, has support for asynchronous tests, which makes it suitable not only for testing AJAX in the browser but also for testing various asynchronous fixtures in node.js like I/O.


I use jasmine in both the browser and in node.js (via jasmine-node). I also like the jasmine-jquery plugin. Jasmine has some async support built it as well. The jasmine syntax is very nice in CoffeeScript whereas its a little verbose in javascript with so many nested functions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号