Mocha uses a default timeout of 2000 ms. However, if for some reason that does not work for your use case, you can increase the timeout for a particular test. In this lesson, you will learn how to increase the timeout of the test using this.timeout() method.

const bankAccounts = [
{
name: 'John',
id: ,
account: '',
balance:
},
{
name: 'Jane',
id: ,
account: '',
balance:
}
]
module.exports = {
getBalance(id, cb) {
setTimeout(() => {
const { balance } = bankAccounts.find(a => a.id === id);
if (!balance) cb('could not find balance');
cb(null, balance)
}, )
}
}
const { expect } = require('chai');
const bankAccount = require('../modules/bank-account'); describe('BankAccount',function(){
this.timeout();
it('should get the balance', function(done){
bankAccount.getBalance(,(err, balance) => {
if(err){
throw err;
}
expect(balance).to.equals();
done();
})
})
})

[Unit Testing] Set the timeout of a Test in Mocha的更多相关文章

  1. [Java Basics3] XML, Unit testing

    What's the difference between DOM and SAX? DOM creates tree-like representation of the XML document ...

  2. Java Unit Testing - JUnit & TestNG

    转自https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html yet another insignifican ...

  3. Unit Testing with NSubstitute

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

  4. Javascript单元测试Unit Testing之QUnit

    body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; }           QUnit是一个基于JQuery的单元测试Uni ...

  5. [Unit Testing] AngularJS Unit Testing - Karma

    Install Karam: npm install -g karma npm install -g karma-cli Init Karam: karma init First test: 1. A ...

  6. C/C++ unit testing tools (39 found)---reference

    http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator ...

  7. Unit testing Cmockery 简单使用

    /********************************************************************** * Unit testing Cmockery 简单使用 ...

  8. Unit Testing a zend-mvc application

    Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in ...

  9. Unit Testing PowerShell Code with Pester

    Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerS ...

随机推荐

  1. openstack 性能优化极致

  2. 【Python】循环语句

    while循环 当条件成立时,循环体的内容可以一直执行,但是避免死循环,需要有一个跳出循环的条件才行. for循环 遍历任何序列(列表和字符串)中的每一个元素 >>> a = [&q ...

  3. python 9:list.reverse()(倒置原列表,可恢复改变)

    bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) bicycles.reverse() #倒置原列 ...

  4. ACM_写数字

    写数字 Time Limit: 2000/1000ms (Java/Others) Problem Description: 把由1开始的自然数依次写下来:123456789101112……,重新分组 ...

  5. [转载]cocos2d-触摸分发原理

    本文由泰然翻译组组长 TXX_糖炒小虾 原创,版权所有,转载请注明出处并通知作者和泰然! 原作 http://www.ityran.com/archives/1326/comment-page-1 触 ...

  6. WPF播放器

    最近由于工作需要,需要做一个播放软件,在网上参考了很多例子,园子里有很多代码.其中最多的就是wpf自带的MediaElement控件,或者VLC视频播放器. 先附我自己查询资料的链接: MediaEm ...

  7. ThinkPHP3.2.3对数据的添、删、改、查(CURD)

    对数据的添加: public function form() { parent::common(); $obj = D('Leave'); if (IS_POST) { $data = I('post ...

  8. poj3009 Curling 2.0 深搜

    PS:以前看到题目这么长就没写下去了.今天做了半天,没做出来.准备看题解,打开了网站都忍住了,最后还是靠自己做出来的.算是一点进步吧. 分析: 题目的意思没明白或者理解有偏差都没办法做题.看样例3和样 ...

  9. hibernate_05_单表操作_对象类型

    本篇使用hibernate输出一个对象(图片) 先写一个java类 package com.imooc.hibernate; import java.sql.Blob; import java.uti ...

  10. JAVA 构建使用 Native 库

    Java 使用Native文件,一般分解为下面几个步骤: 在Java代码中使用native关键字声明一个本地方法 运行javah,获得包含该方法声明的C语言头文件(使用jni编程中的C函数名通常是相关 ...