用于单元测试的Node.js模块 [英] Node.js modules for unit testing

查看:56
本文介绍了用于单元测试的Node.js模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个Web应用程序,该应用程序将jQuery用于Ajax和UI.现在,我想向其中添加单元测试.我希望单元测试可以在单个过程中运行,而无需启动浏览器和单独的Web服务器,我希望它可以与Node.js和以下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.js modules:

  • buster.js
  • jQuery Node.js模块
  • jsdom Node.js模块

我错过了什么吗?有这样的单元测试的例子吗?

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

推荐答案

好吧,您可以使用 assert 编写测试例程,但是我想建议您使用单元测试框架-更具体地说, 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. )

这篇关于用于单元测试的Node.js模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆