[Unit Testing] Set the timeout of a Test in Mocha
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的更多相关文章
- [Java Basics3] XML, Unit testing
What's the difference between DOM and SAX? DOM creates tree-like representation of the XML document ...
- Java Unit Testing - JUnit & TestNG
转自https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html yet another insignifican ...
- Unit Testing with NSubstitute
These are the contents of my training session about unit testing, and also have some introductions a ...
- Javascript单元测试Unit Testing之QUnit
body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; } QUnit是一个基于JQuery的单元测试Uni ...
- [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 ...
- C/C++ unit testing tools (39 found)---reference
http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator ...
- Unit testing Cmockery 简单使用
/********************************************************************** * Unit testing Cmockery 简单使用 ...
- Unit Testing a zend-mvc application
Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in ...
- Unit Testing PowerShell Code with Pester
Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerS ...
随机推荐
- git 设定全局ignore
创建: 2017/08/08 位置: $HOME/.config/git/ignore git/ignore 要自建 内容 https://github.com/github/gitignore ...
- Gold Balanced Lineup(hash)
http://poj.org/problem?id=3274 ***** #include <stdio.h> #include <iostream> #include < ...
- hdu 3037Saving Beans(卢卡斯定理)
Saving Beans Saving Beans Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- 【BZOJ4590】自动刷题机
[思路分析] 比赛的时候想到了用二分+贪心,二分的部分与贪心的部分也写对了,但是由于数据范围未看没有开long long,且二分左端点赋值过小导致WA掉 正解:二分+贪心 二分代码的长度,贪心判断能否 ...
- POJ 1160 DP
题目: poj 1160 题意: 给你n个村庄和它的坐标,现在要在其中一些村庄建m个邮局,想要村庄到最近的邮局距离之和最近. 分析: 这道题.很经典的dp dp[i][j]表示建第i个邮局,覆盖到第j ...
- Asp.net MVC4 Step by Step (1)-路由,控制器,视图
注意:此文需要你有一定Asp.net MVC的基础,很多东西省略了,只是做个提要笔记形式. 要创建一个ASP.NET MVC的Web应用,首先要去下载ASP.NET MVC框架, 可以访问ASP.NE ...
- JavaScript 原型和引用趣点
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...
- python--2、数据类型
字符串 name='jinyudong' 按索引取值.正向取 与 反向取 name['3'] 'y' name['-3'] 'o' 切片(若要使用倒序指定步长为-1),开始或者结束不指定即为到最边上的 ...
- C语言笔记(二)
注释 编译器会用空格代替代码中原来的注释,并先于预处理指令执行/*…*/ 这种形式的注释不能嵌套只要斜杠(/)和星号(*)之间没有空格,都会被当作注释的开始.例如这样:y = x/*p; \ 是一个接 ...
- Python学习①. 基础语法
Python 简介 Python 是一种解释型,面向对象的语言.特点是语法简单,可跨平台 Python 基础语法 交互式编程 交互式编程不需要创建脚本文件,是通过 Python 解释器的交互模式进来编 ...