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(docs.mockFunctions): use SAME JS module system #15486

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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