You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/JestObjectAPI.md
+17-5Lines changed: 17 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1039,30 +1039,42 @@ Use the [`--showSeed`](CLI.md#--showseed) flag to print the seed in the test rep
1039
1039
1040
1040
Returns `true` if test environment has been torn down.
1041
1041
1042
-
### `jest.retryTimes(numRetries, options)`
1042
+
### `jest.retryTimes(numRetries, options?)`
1043
1043
1044
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. `options` are optional. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner! This must live at the top-level of a test file or in a describe block. Retries _will not_ work if `jest.retryTimes()` is called in a `beforeEach` or a `test` block.
1045
-
1046
-
Example in a test:
1044
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
1047
1045
1048
1046
```js
1049
1047
jest.retryTimes(3);
1048
+
1050
1049
test('will fail', () => {
1051
1050
expect(true).toBe(false);
1052
1051
});
1053
1052
```
1054
1053
1055
-
If `logErrorsBeforeRetry` is enabled, Jest will log the error(s) that caused the test to fail to the console, providing visibility on why a retry occurred.
1054
+
If `logErrorsBeforeRetry`option is enabled, error(s) that caused the test to fail will be logged to the console.
1056
1055
1057
1056
```js
1058
1057
jest.retryTimes(3, {logErrorsBeforeRetry:true});
1058
+
1059
1059
test('will fail', () => {
1060
1060
expect(true).toBe(false);
1061
1061
});
1062
1062
```
1063
1063
1064
1064
Returns the `jest` object for chaining.
1065
1065
1066
+
:::caution
1067
+
1068
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
1069
+
1070
+
:::
1071
+
1072
+
:::info
1073
+
1074
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
1075
+
1076
+
:::
1077
+
1066
1078
### `jest.setTimeout(timeout)`
1067
1079
1068
1080
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called. The default timeout interval is 5 seconds if this method is not called.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-25.x/JestObjectAPI.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -660,6 +660,32 @@ Returns the number of fake timers still left to run.
660
660
661
661
## Misc
662
662
663
+
### `jest.retryTimes(numRetries, options?)`
664
+
665
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
666
+
667
+
```js
668
+
jest.retryTimes(3);
669
+
670
+
test('will fail', () => {
671
+
expect(true).toBe(false);
672
+
});
673
+
```
674
+
675
+
Returns the `jest` object for chaining.
676
+
677
+
:::caution
678
+
679
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
680
+
681
+
:::
682
+
683
+
:::info
684
+
685
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
686
+
687
+
:::
688
+
663
689
### `jest.setTimeout(timeout)`
664
690
665
691
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called.
@@ -675,18 +701,3 @@ Example:
675
701
```js
676
702
jest.setTimeout(1000); // 1 second
677
703
```
678
-
679
-
### `jest.retryTimes()`
680
-
681
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. This only works with [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus)!
Copy file name to clipboardExpand all lines: website/versioned_docs/version-26.x/JestObjectAPI.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -680,6 +680,32 @@ When mocking time, `Date.now()` will also be mocked. If you for some reason need
680
680
681
681
## Misc
682
682
683
+
### `jest.retryTimes(numRetries, options?)`
684
+
685
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
686
+
687
+
```js
688
+
jest.retryTimes(3);
689
+
690
+
test('will fail', () => {
691
+
expect(true).toBe(false);
692
+
});
693
+
```
694
+
695
+
Returns the `jest` object for chaining.
696
+
697
+
:::caution
698
+
699
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
700
+
701
+
:::
702
+
703
+
:::info
704
+
705
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
706
+
707
+
:::
708
+
683
709
### `jest.setTimeout(timeout)`
684
710
685
711
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called.
@@ -695,18 +721,3 @@ Example:
695
721
```js
696
722
jest.setTimeout(1000); // 1 second
697
723
```
698
-
699
-
### `jest.retryTimes()`
700
-
701
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. This only works with [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus)!
Copy file name to clipboardExpand all lines: website/versioned_docs/version-27.x/JestObjectAPI.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -720,6 +720,32 @@ When mocking time, `Date.now()` will also be mocked. If you for some reason need
720
720
721
721
## Misc
722
722
723
+
### `jest.retryTimes(numRetries, options?)`
724
+
725
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
726
+
727
+
```js
728
+
jest.retryTimes(3);
729
+
730
+
test('will fail', () => {
731
+
expect(true).toBe(false);
732
+
});
733
+
```
734
+
735
+
Returns the `jest` object for chaining.
736
+
737
+
:::caution
738
+
739
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
740
+
741
+
:::
742
+
743
+
:::info
744
+
745
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
746
+
747
+
:::
748
+
723
749
### `jest.setTimeout(timeout)`
724
750
725
751
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called.
@@ -735,18 +761,3 @@ Example:
735
761
```js
736
762
jest.setTimeout(1000); // 1 second
737
763
```
738
-
739
-
### `jest.retryTimes()`
740
-
741
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner! This must live at the top-level of a test file or in a describe block. Retries _will not_ work if `jest.retryTimes()` is called in a `beforeEach` or a `test` block.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-28.x/JestObjectAPI.md
+33-21Lines changed: 33 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -837,42 +837,54 @@ This function is not available when using legacy fake timers implementation.
837
837
838
838
## Misc
839
839
840
-
### `jest.setTimeout(timeout)`
841
-
842
-
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called.
843
-
844
-
To set timeout intervals on different tests in the same file, use the [`timeout` option on each individual test](GlobalAPI.md#testname-fn-timeout).
845
-
846
-
_Note: The default timeout interval is 5 seconds if this method is not called._
847
-
848
-
_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._
840
+
### `jest.retryTimes(numRetries, options?)`
849
841
850
-
Example:
851
-
852
-
```js
853
-
jest.setTimeout(1000); // 1 second
854
-
```
855
-
856
-
### `jest.retryTimes(numRetries, options)`
857
-
858
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. `options` are optional. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner! This must live at the top-level of a test file or in a describe block. Retries _will not_ work if `jest.retryTimes()` is called in a `beforeEach` or a `test` block.
859
-
860
-
Example in a test:
842
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
861
843
862
844
```js
863
845
jest.retryTimes(3);
846
+
864
847
test('will fail', () => {
865
848
expect(true).toBe(false);
866
849
});
867
850
```
868
851
869
-
If `logErrorsBeforeRetry` is enabled, Jest will log the error(s) that caused the test to fail to the console, providing visibility on why a retry occurred.
852
+
If `logErrorsBeforeRetry`option is enabled, error(s) that caused the test to fail will be logged to the console.
870
853
871
854
```js
872
855
jest.retryTimes(3, {logErrorsBeforeRetry:true});
856
+
873
857
test('will fail', () => {
874
858
expect(true).toBe(false);
875
859
});
876
860
```
877
861
878
862
Returns the `jest` object for chaining.
863
+
864
+
:::caution
865
+
866
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
867
+
868
+
:::
869
+
870
+
:::info
871
+
872
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
873
+
874
+
:::
875
+
876
+
### `jest.setTimeout(timeout)`
877
+
878
+
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called.
879
+
880
+
To set timeout intervals on different tests in the same file, use the [`timeout` option on each individual test](GlobalAPI.md#testname-fn-timeout).
881
+
882
+
_Note: The default timeout interval is 5 seconds if this method is not called._
883
+
884
+
_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._
Copy file name to clipboardExpand all lines: website/versioned_docs/version-29.0/JestObjectAPI.md
+34-22Lines changed: 34 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -837,44 +837,56 @@ This function is not available when using legacy fake timers implementation.
837
837
838
838
## Misc
839
839
840
-
### `jest.setTimeout(timeout)`
840
+
### `jest.retryTimes(numRetries, options?)`
841
841
842
-
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called. The default timeout interval is 5 seconds if this method is not called.
842
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
843
843
844
-
Example:
844
+
```js
845
+
jest.retryTimes(3);
846
+
847
+
test('will fail', () => {
848
+
expect(true).toBe(false);
849
+
});
850
+
```
851
+
852
+
If `logErrorsBeforeRetry` option is enabled, error(s) that caused the test to fail will be logged to the console.
845
853
846
854
```js
847
-
jest.setTimeout(1000); // 1 second
855
+
jest.retryTimes(3, {logErrorsBeforeRetry:true});
856
+
857
+
test('will fail', () => {
858
+
expect(true).toBe(false);
859
+
});
848
860
```
849
861
850
-
:::tip
862
+
Returns the `jest` object for chaining.
851
863
852
-
To set timeout intervals on different tests in the same file, use the [`timeout` option on each individual test](GlobalAPI.md#testname-fn-timeout).
864
+
:::caution
853
865
854
-
If you want to set the timeout for all test files, use [`testTimeout`](Configuration.md#testtimeout-number) configuration option.
866
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
855
867
856
868
:::
857
869
858
-
### `jest.retryTimes(numRetries, options)`
870
+
:::info
859
871
860
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. `options` are optional. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner! This must live at the top-level of a test file or in a describe block. Retries _will not_ work if `jest.retryTimes()` is called in a `beforeEach` or a `test` block.
872
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
861
873
862
-
Example in a test:
874
+
:::
863
875
864
-
```js
865
-
jest.retryTimes(3);
866
-
test('will fail', () => {
867
-
expect(true).toBe(false);
868
-
});
869
-
```
876
+
### `jest.setTimeout(timeout)`
877
+
878
+
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called. The default timeout interval is 5 seconds if this method is not called.
870
879
871
-
If `logErrorsBeforeRetry` is enabled, Jest will log the error(s) that caused the test to fail to the console, providing visibility on why a retry occurred.
880
+
Example:
872
881
873
882
```js
874
-
jest.retryTimes(3, {logErrorsBeforeRetry:true});
875
-
test('will fail', () => {
876
-
expect(true).toBe(false);
877
-
});
883
+
jest.setTimeout(1000); // 1 second
878
884
```
879
885
880
-
Returns the `jest` object for chaining.
886
+
:::tip
887
+
888
+
To set timeout intervals on different tests in the same file, use the [`timeout` option on each individual test](GlobalAPI.md#testname-fn-timeout).
889
+
890
+
If you want to set the timeout for all test files, use [`testTimeout`](Configuration.md#testtimeout-number) configuration option.
0 commit comments