https://github.com/guanruihua/rh-test
使用测试用例 测试 方法
https://github.com/guanruihua/rh-test
test testing type typescript
Last synced: 4 months ago
JSON representation
使用测试用例 测试 方法
- Host: GitHub
- URL: https://github.com/guanruihua/rh-test
- Owner: guanruihua
- Created: 2022-11-02T09:46:16.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-26T15:32:30.000Z (over 3 years ago)
- Last Synced: 2025-05-26T21:42:11.359Z (about 1 year ago)
- Topics: test, testing, type, typescript
- Language: TypeScript
- Homepage:
- Size: 122 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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, ...)`
- 方法的参数加了默认值