From 5e25c2a79aea92bef3a476c09766878f092e46a8 Mon Sep 17 00:00:00 2001 From: Jonathan Sharpe Date: Sun, 22 Sep 2024 00:23:57 +0100 Subject: [PATCH] doc: cover --experimental-test-module-mocks flag PR-URL: https://github.com/nodejs/node/pull/55021 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow Reviewed-By: James M Snell --- doc/api/test.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 26c19b8aab5925..99e4b452f1f561 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -2112,8 +2112,10 @@ added: v22.3.0 This function is used to mock the exports of ECMAScript modules, CommonJS modules, and Node.js builtin modules. Any references to the original module -prior to mocking are not impacted. The following example demonstrates how a mock -is created for a module. +prior to mocking are not impacted. In order to enable module mocking, Node.js must +be started with the [`--experimental-test-module-mocks`][] command-line flag. + +The following example demonstrates how a mock is created for a module. ```js test('mocks a builtin module in both module systems', async (t) => { @@ -3561,6 +3563,7 @@ Can be used to abort test subtasks when the test has been aborted. [TAP]: https://testanything.org/ [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage +[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks [`--experimental-test-snapshots`]: cli.md#--experimental-test-snapshots [`--import`]: cli.md#--importmodule [`--test-concurrency`]: cli.md#--test-concurrency