Node.js modules for unit-testing

最后都变了- 提交于 2019-12-22 00:52:45

问题


Suppose I have a web application, which uses jquery for ajax and UI. Now I would like to add unit-tests to it. I would like the unit-tests to run in a single process without launching browsers and separate web servers and I hope it is doable with the node.js and the following node modules:

  • buster.js
  • jquery node module
  • jsdom node module

Am I missing something? Is there any example of such unit-tests?


回答1:


Well, you can write your test routines with assert, but I'd like to recommend using unit-testing frameworks - more specifically, nodeunit. There's a neat article describing how to use this module to simplify unit testing.

And may I say there's actually a bunch of threads here with (ahem...) the same question - for example, this one, with plenty of choices. )




回答2:


Have you tested "assert" module? It's included in standard NodeJS, and you can do something like:

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


来源:https://stackoverflow.com/questions/11169335/node-js-modules-for-unit-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!