如果我使用TypeScript将一个笑话测试封装在一个函数中,那么预期的返回类型应该是什么?谢谢。
const foo:JestReturnType = () => test('this is a test', expect(true).toBeTruthy());
答案 0 :(得分:1)
test
或it
的返回值为void
:
const foo = (): void =>
test('this is a test', () => {
expect(true).toBeTruthy();
});
describe('test suites', () => {
foo();
});
单元测试结果:
PASS src/stackoverflow/58310060/index.spec.ts (10.251s)
test suites
✓ this is a test (6ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 12.401s
源代码:https://github.com/mrdulin/jest-codelab/tree/master/src/stackoverflow/58310060