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 项目开发规范

    参考:https://fsdhub.com/books/laravel-specification

  2. TypeScript 入门指南

    你是否听过 TypeScript? TypeScript 是微软开发的 JavaScript 的超集,TypeScript兼容JavaScript,可以载入JavaScript代码然后运行.TypeS ...

  3. 点滴积累【JS】---JS小功能(button选择颜色)

    效果: 代码: <head runat="server"> <title></title> <style type="text/ ...

  4. 【LeetCode】Sort Colors 解题报告

    [题目] Given an array with n objects colored red, white or blue, sort them so that objects of the same ...

  5. 关于Unity实现游戏录制功能的思考

    录制无非两种做法,录制操作和录制行为. 录制操作要考虑到随机行为,但其实也可以两者混合.如果随机行为过多,并且随机行为无法用种子复现,可以完全用录制的方式 最后再统一压缩 这里yy的就是录制行为的做法 ...

  6. android-退出动画无效

    在调用 overridePendingTransition(R.anim.anim_scale_in, R.anim.anim_scale_out); 方法设置某个Activity进入和退出动画的时候 ...

  7. #include""和#include<>的区别

    一般来说,就是搜索路径不同 #include ""先去搜用户当前路径(也就是调用编译器的路径),然后再去搜用户用-I选项指定的路径,最后再去搜索编译器默认指定的路径(也就是所谓的系 ...

  8. log4j2配合slf4j使用

    说明 log4j2被用于日志输出,相信绝大多数程序猿都对此不陌生.笔者刚接触log4j2,因此记个博客备用. log4j2是一个日志框架,slf4j是日志框架接口,之所以使用log4j2和slf4j搭 ...

  9. hive export import命令

    EXPORT TABLE stu_p TO 导入表(必须明白导出表,导出表是将表的元数据,数据导出到hdfs上.)讲一个导出的表导入到数据库中,这个hdfs_path 是一个导出表的文件夹 impor ...

  10. 碉堡完整的高性能PHP应用服务器appserver

    完全企业级的开发模式,是一个多线程的 PHP 应用服务器,实现真正多线程的 PHP 编程,高效安全而且快速,以Magento 为例比基于 Nginx的标准安装要快 50%.概念上非常像 Java 的 ...