Skip to content

Commit e416d58

Browse files
committed
doc(docs.mockFunctions): use SAME JS module system
1 parent bacb7de commit e416d58

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/MockFunctions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ There are two ways to mock functions: Either by creating a mock function to use
1212
Let's imagine we're testing an implementation of a function `forEach`, which invokes a callback for each item in a supplied array.
1313

1414
```js title="forEach.js"
15-
export function forEach(items, callback) {
15+
function forEach(items, callback) {
1616
for (const item of items) {
1717
callback(item);
1818
}
1919
}
20+
module.exports = forEach;
2021
```
2122

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

0 commit comments

Comments
 (0)