node.js的单元测试框架,专门支持测试异步代码? [英] Unit testing framework for node.js that specifically supports testing async code?

查看:93
本文介绍了node.js的单元测试框架,专门支持测试异步代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

node.js模块列表中列出了30多个测试框架......

There are 30+ testing frameworks listed on the node.js module list...

哪些框架最受欢迎?它们的优点和缺点是什么?

Which frameworks are most popular? And what are their pros and cons?

我正在寻找一个支持单元测试代码的框架,该代码具有大量异步回调(可能与大多数其他节点项目一样) )。此外,我正在寻找一些相当简单而又小而不复杂的东西。

I'm looking for a framework that supports unit testing of code that has a lot of async callbacks (probably like most other node projects). Also, I'm looking for something rather simple and small than complex.

到目前为止,我已经研究过:

So far I've looked into:


  • Nodeunit 非常简单,并且通过让您定义预期的断言数来支持异步代码调用和测试完成时。

  • Vowsjs 看起来很有趣。允许您很好地构建测试并具有许多高级功能。不确定这些功能是否真的有用,或者它们是否相反?

  • Nodeunit is straightforward and supports async code by letting you define how many assertions you expect to be called and when a test is done.
  • Vowsjs looks interesting. Allows you to nicely structure the tests and comes with many advanced features. Not sure whether these features are actually useful, through, or if they rather stand in your way?

推荐答案

expresso 誓言是最受欢迎的选项。虽然有很多好的选择。 更新:截至2011年11月,摩卡 expresso ,根据 expresso 存储库。 should.js 通常与摩卡允许BDD风格的断言。

expresso and vows are the most popular options. Although there are many good options out there. Update: As of Nov./2011, Mocha is the successor to expresso, according to the Readme.md at the expresso repository. should.js is often used with Mocha to allow BDD-style assertions.

无论你选择什么,我建议使用轻轻地存根核心或第三方模块。

Whatever you choose, I recommend using gently to stub core or third party modules.

我使用/维护 testosterone ,一个小型测试框架,可以连续测试,因此您可以轻轻地滥用。虽然没有那么多人使用它。

I use/maintain testosterone, a little testing framework that runs test on serial so you can abuse gently. Not so many people using it though.

这篇关于node.js的单元测试框架,专门支持测试异步代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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