对单元测试的Node.js模块模块、单元测试、Node、js

2023-09-10 17:04:10 作者:因为我的勇气

假设我有一个Web应用程序,它使用的jQuery AJAX 和UI。现在,我想单元测试添加到它。我想单元测试,以在一个进程中运行,而无需启动浏览器和独立的Web服务器,我希望这是可行的的node.js 及以下节点模块:

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 节点模块 jsdom 节点模块 buster.js jquery node module jsdom node module

我缺少的东西?有没有这样的单元测试任何实际的例子?

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

推荐答案

好了,你可以写你的测试例程断言,但我想用推荐单位-testing框架 - 更确切地说, nodeunit 。有一个整洁的文章描述如何使用这个模块来简化单元测试。

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. )