镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
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
18 changes: 10 additions & 8 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const callsfunc = tracker.calls(func);
callsfunc(1, 2, 3);

assert.deepStrictEqual(tracker.getCalls(callsfunc),
[{ thisArg: this, arguments: [1, 2, 3 ] }]);
[{ thisArg: undefined, arguments: [1, 2, 3] }]);
```

```cjs
Expand All @@ -362,7 +362,7 @@ const callsfunc = tracker.calls(func);
callsfunc(1, 2, 3);

assert.deepStrictEqual(tracker.getCalls(callsfunc),
[{ thisArg: this, arguments: [1, 2, 3 ] }]);
[{ thisArg: undefined, arguments: [1, 2, 3] }]);
```

### `tracker.report()`
Expand Down Expand Up @@ -399,7 +399,7 @@ function func() {}
const callsfunc = tracker.calls(func, 2);

// Returns an array containing information on callsfunc()
tracker.report();
console.log(tracker.report());
// [
// {
// message: 'Expected the func function to be executed 2 time(s) but was
Expand All @@ -425,7 +425,7 @@ function func() {}
const callsfunc = tracker.calls(func, 2);

// Returns an array containing information on callsfunc()
tracker.report();
console.log(tracker.report());
// [
// {
// message: 'Expected the func function to be executed 2 time(s) but was
Expand Down Expand Up @@ -462,24 +462,26 @@ const callsfunc = tracker.calls(func);

callsfunc();
// Tracker was called once
tracker.getCalls(callsfunc).length === 1;
assert.strictEqual(tracker.getCalls(callsfunc).length, 1);

tracker.reset(callsfunc);
tracker.getCalls(callsfunc).length === 0;
assert.strictEqual(tracker.getCalls(callsfunc).length, 0);
```

```cjs
const assert = require('node:assert');

const tracker = new assert.CallTracker();

function func() {}
const callsfunc = tracker.calls(func);

callsfunc();
// Tracker was called once
tracker.getCalls(callsfunc).length === 1;
assert.strictEqual(tracker.getCalls(callsfunc).length, 1);

tracker.reset(callsfunc);
tracker.getCalls(callsfunc).length === 0;
assert.strictEqual(tracker.getCalls(callsfunc).length, 0);
```

### `tracker.verify()`
Expand Down