[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 ...
随机推荐
- expectation-maximization algorithm ---- PRML读书笔记
An elegant and powerful method for finding maximum likelihood solutions for models with latent varia ...
- android sdk 更新失败问题解决办法
网上几乎都是这么说的 1.设置tools下的options,然后点击菜单packages下的reload 2.然后就会出现列表在点install进行安装 但是在更新时莫名其妙的也会出现错误 解决类似这 ...
- PCB MS SQL 排序应用---SQL相邻数据区间值求解
其中一篇 博文中有写<PCB MS SQL 排序应用---相邻数据且相同合并处理>此篇有也应相用也同的技巧,实现相邻数据区间值求解 示例: 原数据:处理前 求出区间值:处理后 SQL 代码 ...
- PCB WCF Web接口增减参数后,在客户端不更新的情况,是否影响客户端,评估测试
1.目的:由于接口众多,服务端变更接口,会造成服务停用更新,造成客户端不能使用或报错, 在此评估[Web中心]此服务端,接口接口参数增加或减少,是否对客户端造成影响 2.评估内容:服务端增加单值参数, ...
- web动画小结
前端写动画,无非两种方案,一种是通过css,另一种是js css的方案: 1.transform的单独使用 (IE9+) rotate(90deg) 2d旋转,也可以理解为沿着3D的Z轴旋转 rota ...
- go之数组
一.数组概念 go语言提供了数组类型的数据结构 数组是具有 [唯一类型] 的一组 [固定长度] 的数据项序列,这种类型可以是任意类型 二.数组声明 var variable_name [SIZE]va ...
- TCP/IP详解(一)
SYN中的MSS选项是告诉对端,本端在本地连接的每个TCP分节中愿意接收的最大数据量.发送端TCP使用接收端的MSS值作为发送分节的最大大小. TCP半关闭使用的情况较少,可用于通知对端本端数据已输入 ...
- Cracking the Coding Interview 8.5
Implement an algorithm to print all valid combinations of n-pairs of parentheses #include<stdio.h ...
- xx网络--工具集合
-- D:\workspace\bajie_projram\BJ.srfcb\BJ.srfcb\BJ.srfcb 8jielicai_New\App_Code\common\pg.cs---GetHt ...
- # Nginx设置浏览器缓存
配置语法 在location或if段里,来写. 格式 expires 30s; expires 30m; expires 2h; expires 30d; (注意:服务器的日期要准确,如果服务器的日期 ...