We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bacb7de commit e416d58Copy full SHA for e416d58
docs/MockFunctions.md
@@ -12,11 +12,12 @@ There are two ways to mock functions: Either by creating a mock function to use
12
Let's imagine we're testing an implementation of a function `forEach`, which invokes a callback for each item in a supplied array.
13
14
```js title="forEach.js"
15
-export function forEach(items, callback) {
+function forEach(items, callback) {
16
for (const item of items) {
17
callback(item);
18
}
19
20
+module.exports = forEach;
21
```
22
23
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