diff --git a/packages/jest-types/src/Circus.ts b/packages/jest-types/src/Circus.ts index c5f941efc11c..3dab1d8d7abe 100644 --- a/packages/jest-types/src/Circus.ts +++ b/packages/jest-types/src/Circus.ts @@ -20,7 +20,7 @@ export type HookFn = Global.HookFn; export type AsyncFn = TestFn | HookFn; export type SharedHookType = 'afterAll' | 'beforeAll'; export type HookType = SharedHookType | 'afterEach' | 'beforeEach'; -export type TestContext = Record; +export type TestContext = Global.TestContext; export type Exception = any; // Since in JS anything can be thrown as an error. export type FormattedError = string; // String representation of error. export type Hook = { diff --git a/packages/jest-types/src/Global.ts b/packages/jest-types/src/Global.ts index f02c07ab6f1d..46a4d0669b96 100644 --- a/packages/jest-types/src/Global.ts +++ b/packages/jest-types/src/Global.ts @@ -12,10 +12,20 @@ type TestReturnValuePromise = Promise; type TestReturnValueGenerator = Generator; export type TestReturnValue = ValidTestReturnValues | TestReturnValuePromise; +export type TestContext = Record; + export type DoneFn = (reason?: string | Error) => void; -export type DoneTakingTestFn = (done: DoneFn) => ValidTestReturnValues; -export type PromiseReturningTestFn = () => TestReturnValue; -export type GeneratorReturningTestFn = () => TestReturnValueGenerator; +// these should not be undefined +export type DoneTakingTestFn = ( + this: TestContext | undefined, + done: DoneFn, +) => ValidTestReturnValues; +export type PromiseReturningTestFn = ( + this: TestContext | undefined, +) => TestReturnValue; +export type GeneratorReturningTestFn = ( + this: TestContext | undefined, +) => TestReturnValueGenerator; export type TestName = string; export type TestFn =