Skip to content

Commit

Permalink
update api description, add type test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadimchesh committed Mar 20, 2024
1 parent b58faf3 commit 6cffa1b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ test('will fail', () => {
});
```

`immediately` option is used to retry the failed test immediately.
`immediately` option is used to retry the failed test immediately after the failure. If this option is not specified, the tests are retried after Jest is finished running all test in a file.

```js
jest.retryTimes(3, {immediately: true});
Expand Down
1 change: 1 addition & 0 deletions packages/jest-circus/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const _runTestsForDescribeBlock = async (
(global as Global.Global)[WAIT_BEFORE_RETRY] as string,
10,
) || 0;

const retryImmediately: boolean =
// eslint-disable-next-line no-restricted-globals
((global as Global.Global)[IMMEDIATELY] as any) || false;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-environment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ export interface Jest {
retryTimes(
numRetries: number,
options?: {
immediately?: boolean;
logErrorsBeforeRetry?: boolean;
waitBeforeRetry?: number;
immediately?: boolean;
},
): Jest;
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-types/__typetests__/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ expect(jest.retryTimes(3, {logErrorsBeforeRetry: 'all'})).type.toRaiseError();
expect(jest.retryTimes({logErrorsBeforeRetry: true})).type.toRaiseError();
expect(jest.retryTimes(3, {waitBeforeRetry: 1000})).type.toEqual<typeof jest>();
expect(jest.retryTimes(3, {waitBeforeRetry: true})).type.toRaiseError();
expect(jest.retryTimes(3, {immediately: true})).type.toEqual<typeof jest>();
expect(jest.retryTimes(3, {immediately: 'now'})).type.toRaiseError();
expect(jest.retryTimes(3, {immediately: 1000})).type.toRaiseError();
expect(jest.retryTimes({logErrorsBeforeRetry: 'all'})).type.toRaiseError();
expect(jest.retryTimes()).type.toRaiseError();

Expand Down

0 comments on commit 6cffa1b

Please sign in to comment.