An open API service indexing awesome lists of open source software.

https://github.com/guanruihua/rh-test

使用测试用例 测试 方法
https://github.com/guanruihua/rh-test

test testing type typescript

Last synced: 4 months ago
JSON representation

使用测试用例 测试 方法

Awesome Lists containing this project

README

          

# 描述

- 更名为 **unit-test-js**
- 添加测试用例来执行是否符合预期

## `test(name:string, func:Func, ...cases: CaseUnit)`

- 泛型
- `Param` : 测试用例的参数类型
- `Tobe`: 测试用例的结果类型
- 参数
- `name`: 用例名
- `func`: 待测试的方法
- `...cases`: 测试用例

```ts

export type CaseUnit = {
func?: any
name?: string
param?: Param
params?: Param | Param[]
tobe?: _Tobe
tobes?: _Tobe[]
warningTobe?: _Tobe
warningTobes?: _Tobe[]
type?: CaseUnitType
paramType?: CaseUnitParamType
/**
* 测试执行前
*/
before?: callback
/**
* 判断结果是否正确前
*/
beforeEqual?: callback
/**
* 打印结果前
*/
after?: callback
/**
* @title 超时时间
* @default 2000
*/
timeout?: number | 'Infinite'
run?: {
actual: any,
runTime: number,
error?: string
}
[key: string]: any
}

test(name, func, {...},{...}, ...)
// 可以打印出相应的结果
```

## `equal`

- 等同 `test(name, tobe, ...)`
- 方法的参数加了默认值