[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 ...
随机推荐
- easyui+struts2:datagrid无法不能得到数据
转自:https://bbs.csdn.net/topics/390980437 easyui+struts2:datagrid无法访问到指定action: userlist.jsp部分代码: XML ...
- scws
SCWS 是 Simple Chinese Word Segmentation 的首字母缩写(即:简易中文分词系统). 这是一套基于词频词典的机械式中文分词引擎,它能将一整段的中文文本基本正确地切分成 ...
- Angular 显示英雄列表
在本页面,你将扩展<英雄指南>应用,让它显示一个英雄列表, 并允许用户选择一个英雄,查看该英雄的详细信息. 创建模拟(mock)英雄数据 你需要一些英雄数据以供显示. 最终,你会从远端的数 ...
- SpringBoot + MyBatis(注解版),常用的SQL方法
一.新建项目及配置 1.1 新建一个SpringBoot项目,并在pom.xml下加入以下代码 <dependency> <groupId>org.mybatis.spring ...
- POJ 3083 BFS+DFS 40行
题意:给你一个迷宫. 先输出当左转优先的时候走的路程长度,再输出当右转优先时走的路程长度,最后输出从起点到终点的最短路程长度. 嗯嗯 奴哥活跃气氛的题.随便写了写.. 此题 知道了思路以后就是水题了. ...
- Redis学习笔记(五)- 数据类型之set类型
Redis 的set是string类型的无序集合.set元素最大可以包含(2的32次方-1)个元素.set的是通过hash table实现的,所以添加,删除,查找的复杂度都是O(1).hash tab ...
- rabbit channel参数
channel.exchangeDeclare() channel.ExchangeDeclare(string exchange: "cjlTest",string type: ...
- QS之force(2)
Examples 1) Force input1 to 0 at the current simulator time. force input1 0 2) Force the fourth elem ...
- react基础篇一
jsx简介 const element = <h1>Hello, world!</h1>; 这种看起来可能有些奇怪的标签语法既不是字符串也不是 HTML. 它被称为 JSX, ...
- window 8 电脑操作服务集合(网址)
如何开启Win8远程桌面 http://jingyan.baidu.com/album/48206aeae06627216ad6b3bf.html?picindex=2 Win8.1用户账户的配置管理 ...