Skip to content

Commit

Permalink
promises can resolve to anything
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Dec 5, 2020
1 parent fbb8999 commit 0164a7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/jest-types/src/Global.ts
Expand Up @@ -8,8 +8,8 @@
import type {CoverageMapData} from 'istanbul-lib-coverage';

export type ValidTestReturnValues = void | undefined;
type TestReturnValuePromise = Promise<ValidTestReturnValues>;
type TestReturnValueGenerator = Generator<void, ValidTestReturnValues, void>;
type TestReturnValuePromise = Promise<unknown>;
type TestReturnValueGenerator = Generator<void, unknown, void>;
export type TestReturnValue = ValidTestReturnValues | TestReturnValuePromise;

export type TestContext = Record<string, unknown>;
Expand Down
8 changes: 6 additions & 2 deletions test-types/top-level-globals.test.ts
Expand Up @@ -70,14 +70,18 @@ expectError(test(timeout, fn));

// wrong return value
expectError(test(testName, () => 42));
expectError(test(testName, async () => 42));

// mixing done callback and promise
// mixing done callback and promise/generator
expectError(
test(testName, async done => {
done();
}),
);
expectError(
test(testName, function* (done) {
done();
}),
);

expectType<void>(test(testName, fn));
expectType<void>(test(testName, asyncFn));
Expand Down

0 comments on commit 0164a7a

Please sign in to comment.