Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): specify an error message in Timermocks #12248

Merged
merged 4 commits into from Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/TimerMocks.md
Expand Up @@ -79,7 +79,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down
8 changes: 7 additions & 1 deletion website/versioned_docs/version-25.x/TimerMocks.md
Expand Up @@ -63,7 +63,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down
8 changes: 7 additions & 1 deletion website/versioned_docs/version-26.x/TimerMocks.md
Expand Up @@ -63,7 +63,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down
8 changes: 7 additions & 1 deletion website/versioned_docs/version-27.0/TimerMocks.md
Expand Up @@ -81,7 +81,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down
8 changes: 7 additions & 1 deletion website/versioned_docs/version-27.1/TimerMocks.md
Expand Up @@ -81,7 +81,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down
9 changes: 8 additions & 1 deletion website/versioned_docs/version-27.2/TimerMocks.md
Expand Up @@ -60,6 +60,7 @@ All of the following functions need fake timers to be set, either by `jest.useFa
Another test we might want to write for this module is one that asserts that the callback is called after 1 second. To do this, we're going to use Jest's timer control APIs to fast-forward time right in the middle of the test:

```javascript
jest.useFakeTimers();
test('calls the callback after 1 second', () => {
const timerGame = require('../timerGame');
const callback = jest.fn();
Expand All @@ -80,7 +81,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down
8 changes: 7 additions & 1 deletion website/versioned_docs/version-27.4/TimerMocks.md
Expand Up @@ -81,7 +81,13 @@ test('calls the callback after 1 second', () => {

## Run Pending Timers

There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop… so something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:
There are also scenarios where you might have a recursive timer -- that is a timer that sets a new timer in its own callback. For these, running all the timers would be an endless loop, throwing the following error:

```
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
```

So something like `jest.runAllTimers()` is not desirable. For these cases you might use `jest.runOnlyPendingTimers()`:

```javascript title="infiniteTimerGame.js"
'use strict';
Expand Down