From 6bc7b7e6f497b7a5d5ea7c92cdf88df4682aec75 Mon Sep 17 00:00:00 2001 From: MURAKAMI Masahiko Date: Fri, 9 Dec 2022 05:28:38 +0900 Subject: [PATCH] test_runner: add resetCalls to MockFunctionContext This commit allows tests in test runner to reset the calls of mock function Refs: https://github.com/nodejs/node/pull/45326#discussion_r1014728750 PR-URL: https://github.com/nodejs/node/pull/45710 Reviewed-By: Colin Ihrig Reviewed-By: Moshe Atlow Reviewed-By: Yagiz Nizipli --- doc/api/test.md | 8 ++++++++ lib/internal/test_runner/mock.js | 4 ++++ test/parallel/test-runner-mocking.js | 17 +++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/doc/api/test.md b/doc/api/test.md index 3588c6d6acd45b..c8f8dfd0f62c2e 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -870,6 +870,14 @@ test('changes a mock behavior once', (t) => { }); ``` +### `ctx.resetCalls()` + + + +Resets the call history of the mock function. + ### `ctx.restore()`