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. laravel配置文件(自定义配置文件)

    laravel配置文件存放目录config里面的文件是自定加载的,也就是说,你在文件夹里面新建一个custom.php,按配置格式写,是可以正常访问的. 1.读取配置的方法: $value = con ...

  2. 实验c语言不同类型的指针互用(不推荐只是学习用)

    #include <stdio.h> int main(int argc, char *argv[]) { printf("Hello, world\n"); ]; i ...

  3. Sql學習資源

    http://blog.csdn.net/wltica/article/category/1324738/1 SQL Server 整体方案系列: 1. SQL Server 数据归档方案 2. SQ ...

  4. Application Architecture Determines Application Performance

     Application Architecture Determines Application Performance Randy Stafford AppliCATion ARCHiTECTuR ...

  5. FPGA大公司面试笔试数电部分,看看你会多少

    1:什么是同步逻辑和异步逻辑?(汉王) 同步逻辑是时钟之间有固定的因果关系.异步逻辑是各时钟之间没有固定的因果关系. 答案应该与上面问题一致 [补充]:同步时序逻辑电路的特点:各触发器的时钟端全部连接 ...

  6. [iOS]delegate和protocol

    转自:http://haoxiang.org/2011/08/ios-delegate-and-protocol/ 今天上班和同事讨论工程怎么组织的时候涉及到这个话题.iOS开发上对delegate使 ...

  7. Redis_发布订阅(Spring Boot)

    目录 前言 生产者和消费者 发布和订阅 Java实现 注意 转至 http://www.tianmaying.com/tutorial/springboot-redis-message 前言 利用Sp ...

  8. python 同时遍历多个变量

    最近在用python的时候,用到遍历多个变量: import sys import math F58=11491939491.7 F=[11429229079.7,11374540753.7,1132 ...

  9. CCRenderTexture画点出现十字架"歪解"

    在泰然论坛发个了帖子,没有人解答,内容如下: 遇到奇葩问题了,cocos2dx 2.2 CCRenderTexture* tex=CCRenderTexture::create(, ); tex-&g ...

  10. Ubuntu 启动项、菜单 改动 防止隐藏

    因为电脑有多个系统,默认的grub引引导菜单是隐藏的,须要略微改动下方可显示 不要直接改动boot/grub/grub.cfg  要直接改动/etc/default/grub,然后update-gru ...