Skip to content

Commit

Permalink
pass this to test callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Dec 5, 2020
1 parent a6d271d commit 4154b0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/jest-types/src/Circus.ts
Expand Up @@ -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<string, unknown>;
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 = {
Expand Down
16 changes: 13 additions & 3 deletions packages/jest-types/src/Global.ts
Expand Up @@ -12,10 +12,20 @@ type TestReturnValuePromise = Promise<unknown>;
type TestReturnValueGenerator = Generator<void, unknown, void>;
export type TestReturnValue = ValidTestReturnValues | TestReturnValuePromise;

export type TestContext = Record<string, unknown>;

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 =
Expand Down

0 comments on commit 4154b0d

Please sign in to comment.