http://www.tuicool.com/articles/rAnaYvn

http://www.tuicool.com/articles/Y73aYn

(contrast stub and mock in java )http://www.cnblogs.com/TankXiao/archive/2012/03/06/2366073.html

http://shaynegui.com/javascript-unit-test-sinonjs/

http://shaynegui.com/javascript-unit-test-sinonjs/

http://sinonjs.org/docs/#spies

模拟输入可以用Sinon,它可以模拟包括ajax调用的各类程序调用来进行测试。也就是用Faker.js来生成软件测试时所需要的各式各样的数据。

test data generator: Faker.js

npm install -g faker-cli

Nodejs的单元测试工具

  1. 测试框架 mocha

  2. 断言库:should.js、expect.js、chai

  3. 覆盖率:istanbul、jscover、blanket

  4. Mock库:muk

  5. 测试私有方法:rewire

  6. Web测试:supertest

  7. 持续集成:Travis-cli

QUnit is very easy to get started with, as you only need to include two files(qunit.css and qunit.js) and a little bit of markup, then you can start writing tests. QUnit is TDD style tests.

Jasmine is easier to get started – it’s all-in-one package will generally get you and a team up and testing much faster, and you’ll be in good hands with it. Jasmine is BDD style tests.

Mocha is significantly more flexible, but you have to piece it together yourself. There is no spy framework built in to Mocha, so most people use sinon.js. There’s no assertion framework built in to Mocha either, so you’ll have to pick one. Chai is the popular one, but there are many, many others available. You can also configure Mocha for BDD (jasmine style) or TDD (QUnit style) easily. But you have to pick and choose how you want Mocha to work. This flexibility is great because you can build the test environment that you really want. But it means you have more work to do, more individual pieces to maintain /  keep up to date, etc.

nodejs unit test related----faker-cli, sinonjs, mock/stub的更多相关文章

  1. angular4.0 安装最新版本的nodejs、npm、@angular/cli的方法

    在使用ng项目的ui框架时,比如ng-zorro.angular Material,需要安装最新版本的@angular/cli: 配置ng-zorro框架 ng-zorro官网:https://ng. ...

  2. Method of offloading iSCSI TCP/IP processing from a host processing unit, and related iSCSI TCP/IP offload engine

    A method of offloading, from a host data processing unit (205), iSCSI TCP/IP processing of data stre ...

  3. 置换测试: Mock, Stub 和其他

    简介 在理想情况下,你所做的所有测试都是能应对你实际代码的高级测试.例如,UI 测试将模拟实际的用户输入(Klaas 在他的文章中有讨论)等等.实但际上,这并非永远都是个好主意.为每个测试用例都访问一 ...

  4. iOS測试——置换測试: Mock, Stub 和其它

    文章地址:http://ryantang.me/blog/2014/08/21/test-doubles/

  5. Unit Testing with NSubstitute

    These are the contents of my training session about unit testing, and also have some introductions a ...

  6. nodeJs 5.0.0 安装配置与nodeJs入门例子学习

    新手学习笔记,高手请自动略过 安装可以先看这篇:http://blog.csdn.net/bushizhuanjia/article/details/7915017 1.首先到官网去下载exe,或者m ...

  7. What's the difference between a stub and mock?

    I believe the biggest distinction is that a stub you have already written with predetermined behavio ...

  8. window下Nodejs的部署

    nodejs http://nodejs.org/#download npm node cli.js install npm -gf //可以安装最新版的NPM node cli.js install ...

  9. vue mock自己总结

    cli安装mock模块 npm   install  mockjs 创建mock文件夹 配置及创建文件 当后端写好真实接口以后,我们只需删掉创建的mock.js文件和在main.js中导入假数据的那行 ...

随机推荐

  1. HashMap实现原理(转)

    来自:http://www.cnblogs.com/xwdreamer/archive/2012/05/14/2499339.html 0.参考文献: hash算法 (hashmap 实现原理) Ja ...

  2. atitit.提升兼容性最佳实践 p825.doc

    atitit.提升兼容性最佳实践 p825.doc 1. Atitit.兼容性的“一加三”策略1 2. 扩展表模式2 3. 同时运行模式2 3.1. 完美的后向兼容性3 3.2. 虚拟机模式3 3.3 ...

  3. [docker]docker日志驱动记录nginx日志情形探究

    这里研究下容器nginx记录日志的集中情况,主要想弄明白,docker的日志--log-driver=fluentd 改成fluentd后,会不会在本地在记录一份日志 整体架构是这样的 情况1: 首先 ...

  4. Cookie的新增,设置与清除

    addCookieBtn.addEventListener('click',function () { document.cookie='imooc=www.imooc.com;expires=201 ...

  5. 0053 用注解方式配置Spring MVC

    按照0052中的办法,如果一个站点设计有1000个请求,那就得写1000个controller,还得配置1000个<bean id="helloController" cla ...

  6. java中final关键字的使用方法

     [java中为什么会有final变量]: final这个关键字的含义是"这是无法改变的"或者"终态的": 那么为什么要阻止改变呢? java语言的发明者可 ...

  7. Spark Standalone与Spark on YARN的几种提交方式

    不多说,直接上干货! Spark Standalone的几种提交方式 别忘了先启动spark集群!!! spark-shell用于调试,spark-submit用于生产. 1.spark-shell ...

  8. 基于ZK的分布式锁实现

    import java.util.concurrent.TimeUnit; import org.apache.curator.framework.CuratorFramework; import o ...

  9. 基于jQuery的让非HTML5浏览器支持placeholder属性的代码(转)

    效果图:http://code.google.com/p/jquery-placeholder-js/ 演示代码:http://demo.jb51.net/js/2011/jqueryplacehol ...

  10. 使用AccessibilityService实现微信自己主动抢红包

    近期要实现微信自己主动抢红包的功能.使用AccessibilityService来开发,这里主要写一下逻辑以及注意点. 注意点 1.搜索keyword 我们实现某个功能比方点击等须要找到相应的对象然后 ...