[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 ...
随机推荐
- bzoj2822[AHOI2012]树屋阶梯(卡特兰数)
2822: [AHOI2012]树屋阶梯 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 879 Solved: 513[Submit][Status] ...
- html5的Form新特性
form新增的输入型控件: 名称 说明 图例 email 电子邮箱文本框,显示跟普通的没什么区别 tel 电话号码,pc端不会有明显的变化,但是移动端会自动切换键盘,输入有误不会阻止默认提交 u ...
- Java IO流文件复制/解压的几种方法总结
引言 在JavaWeb项目开发过程,涉及到IO文件的读写操作以及文件的复制copy操作是作为一个程序员不可获取的知识,那接下来就总结一些copy文件的一些方法,与大家通过学习,如果还有其他更好的方法, ...
- Hive搭建与简单使用
hive搭建与简单使用(1) 标签(空格分隔): hive,mysql hive相当于编译器的组件,他并不存储数据,元数据存储在mysql中,数据则存放在hdfs中,通过hive,可以利用sql语句对 ...
- js数据管理的思考
最近要做一个农场项目,涉及到很多js数据管理的需求,这里也做下总结,不断的总结,再修正内容,也是快速进步的方法. 数据管理几个方面考虑: * 设置(更新)字段值 * 检索,根据id, index, 属 ...
- 【PostgreSQL-9.6.3】表操作语句
1.创建数据表 create table table_name ( 字段1 数据类型[列级别约束条件][默认值], 字段2 数据类型[列级别约束条件][默认值], 字段3 数据类型[列级别约束条件][ ...
- 【sqli-labs】 less5 GET - Double Injection - Single Quotes - String (双注入GET单引号字符型注入)
双注入查询可以查看这两篇介绍 https://www.2cto.com/article/201302/190763.html https://www.2cto.com/article/201303/1 ...
- UNIX SOCKET编程简介
1 . Layered Model of Networking Socket 编程的层次模型如下图所示, 最上面是应用层,应用层下面的是 SOCKET API 层,再下面是传输层和网络层 ...
- 数据库Day3之SQL Server 触发器
最近在做一个人事管理系统写了几个简单的触发器 1.在删除员工信息表中员工信息时结果区提示被删除员工信息 create trigger teston 员工信息表after deleteasselect ...
- 【双系统】windows 和 Ubuntu 双系统安装
本博客主要讲述如何在已安装windows系统的计算机上安装Ubuntu双系统,涉及系统安装和相应磁盘空间分配等问题. 所需环境: 电脑已安装windows系统 下载Ubuntu16.04系统镜像 ...