Node.js模块进行unit testing

假设我有一个Web应用程序,它使用jqueryajax 。 现在我想添加unit testing。 我希望unit testing能够在单个进程中运行,而不需要启动浏览器和单独的web服务器,我希望可以通过node.js和下面的node模块来实现:

  • buster.js
  • jquery节点模块
  • jsdom节点模块

我错过了什么吗? 有没有这样的unit testing的例子?

那么,你可以写你的testing例程与assert ,但我想推荐使用unit testing框架 – 更具体地说, nodeunit 。 有一篇整洁的文章描述如何使用这个模块来简化unit testing。

而且我可以说,实际上这里有一堆线程(ahem …)是同一个问题 – 例如, 这个问题有很多select。 )

你testing过“assert”模块吗? 它包含在标准的NodeJS中,你可以做如下的事情:

 var assert = require('assert'); assert.ok(true, 'test fails');