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

doc: fix wrong variable name in example of timers.tick() #53147

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -2234,10 +2234,10 @@ test('mocks setTimeout to be executed synchronously without having to actually w
const nineSecs = 9000;
setTimeout(fn, nineSecs);

const twoSeconds = 3000;
context.mock.timers.tick(twoSeconds);
context.mock.timers.tick(twoSeconds);
context.mock.timers.tick(twoSeconds);
const threeSeconds = 3000;
context.mock.timers.tick(threeSeconds);
context.mock.timers.tick(threeSeconds);
context.mock.timers.tick(threeSeconds);

assert.strictEqual(fn.mock.callCount(), 1);
});
Expand All @@ -2253,10 +2253,10 @@ test('mocks setTimeout to be executed synchronously without having to actually w
const nineSecs = 9000;
setTimeout(fn, nineSecs);

const twoSeconds = 3000;
context.mock.timers.tick(twoSeconds);
context.mock.timers.tick(twoSeconds);
context.mock.timers.tick(twoSeconds);
const threeSeconds = 3000;
context.mock.timers.tick(threeSeconds);
context.mock.timers.tick(threeSeconds);
context.mock.timers.tick(threeSeconds);

assert.strictEqual(fn.mock.callCount(), 1);
});
Expand Down Expand Up @@ -2306,8 +2306,8 @@ test('mocks setTimeout to be executed synchronously without having to actually w

#### Using clear functions

As mentioned, all clear functions from timers (`clearTimeout` and `clearInterval`)
are implicity mocked. Take a look at this example using `setTimeout`:
As mentioned, all clear functions from timers (`clearTimeout`, `clearInterval`,and
`clearImmediate`) are implicitly mocked. Take a look at this example using `setTimeout`:

```mjs
import assert from 'node:assert';
Expand All @@ -2320,7 +2320,7 @@ test('mocks setTimeout to be executed synchronously without having to actually w
context.mock.timers.enable({ apis: ['setTimeout'] });
const id = setTimeout(fn, 9999);

// Implicity mocked as well
// Implicitly mocked as well
clearTimeout(id);
context.mock.timers.tick(9999);

Expand All @@ -2340,7 +2340,7 @@ test('mocks setTimeout to be executed synchronously without having to actually w
context.mock.timers.enable({ apis: ['setTimeout'] });
const id = setTimeout(fn, 9999);

// Implicity mocked as well
// Implicitly mocked as well
clearTimeout(id);
context.mock.timers.tick(9999);

Expand Down
Loading