Skip to content
Merged
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion docs/MockFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ There are two ways to mock functions: Either by creating a mock function to use
Let's imagine we're testing an implementation of a function `forEach`, which invokes a callback for each item in a supplied array.

```js title="forEach.js"
export function forEach(items, callback) {
function forEach(items, callback) {
for (const item of items) {
callback(item);
}
}
module.exports = forEach;
```

To test this function, we can use a mock function, and inspect the mock's state to ensure the callback is invoked as expected.
Expand Down
Loading