From e416d5891660c9d4f39892aa826b6c2f3ca31e9f Mon Sep 17 00:00:00 2001 From: dancer1325 Date: Mon, 3 Feb 2025 15:30:50 +0100 Subject: [PATCH] doc(docs.mockFunctions): use SAME JS module system --- docs/MockFunctions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/MockFunctions.md b/docs/MockFunctions.md index 0801739e8406..b5aeb3b78732 100644 --- a/docs/MockFunctions.md +++ b/docs/MockFunctions.md @@ -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.