From 3391e583b4110a7ef9e709d49d01d08c1948c68e Mon Sep 17 00:00:00 2001 From: Oshri Asulin <114335827+OshriAsulin@users.noreply.github.com> Date: Mon, 4 Sep 2023 21:15:00 +0300 Subject: [PATCH 1/4] doc: fix missing imports in `test.run` code examples The script was missing necessary imports for the `run` function and the `path` module, causing it to fail. This commit adds the missing imports and resolves the issue. - Import `run` from the appropriate module. - Import `path` to resolve file paths. The script should now run without errors. --- doc/api/test.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/test.md b/doc/api/test.md index ab58bf0e312654..fc0a2395850a52 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -907,8 +907,9 @@ changes: * Returns: {TestsStream} ```mjs -import { tap } from 'node:test/reporters'; +import { tap, run } from 'node:test/reporters'; import process from 'node:process'; +import path from 'path'; run({ files: [path.resolve('./tests/test.js')] }) .compose(tap) From 79b707f21e7c72cd4a23ac8087b664863fb96610 Mon Sep 17 00:00:00 2001 From: Oshri Asulin <114335827+OshriAsulin@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:22:27 +0300 Subject: [PATCH 2/4] Update cjs syntax This commit enhances the script by addressing missing imports for the 'run' function and the 'path' module, which previously resulted in script failure. The following improvements have been made: Imported 'run' from the appropriate module via require to ensure correct functionality. Imported 'path' via require to facilitate proper file path resolution. Imported 'process' via require to include this essential module. These changes resolve the issue of missing dependencies execution. --- doc/api/test.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/test.md b/doc/api/test.md index fc0a2395850a52..684d570dc626eb 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -917,7 +917,9 @@ run({ files: [path.resolve('./tests/test.js')] }) ``` ```cjs -const { tap } = require('node:test/reporters'); +const { tap, run } = require('node:test/reporters'); +const process = require('process'); +const path = require('path'); run({ files: [path.resolve('./tests/test.js')] }) .compose(tap) From 90c94c2efcb01933770944f94bdf3143670e461d Mon Sep 17 00:00:00 2001 From: Oshri Asulin <114335827+OshriAsulin@users.noreply.github.com> Date: Wed, 6 Sep 2023 02:38:33 +0300 Subject: [PATCH 3/4] fix: Update import statements In this commit, I've refactored the import statements and destructuring assignments in the codebase to enhance code organization and maintainability. The primary changes are as follows: 1. Replaced the import statement: - From: `import { tap, run } from 'node:test/reporters';` - To: - `import { run } from 'node:test';` - `import { tap } from 'node:test/reporters';` 2. Reorganized destructuring assignments: - From: ``` const { tap, run } = require('node:test/reporters'); const process = require('process'); ``` - To: ``` const { run } = require('node:test'); const { tap } = require('node:test/reporters'); ``` --- doc/api/test.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 684d570dc626eb..cff6e44ff06f42 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -907,7 +907,8 @@ changes: * Returns: {TestsStream} ```mjs -import { tap, run } from 'node:test/reporters'; +import { tap } from 'node:test/reporters'; +import { run } from 'node:test'; import process from 'node:process'; import path from 'path'; @@ -917,8 +918,8 @@ run({ files: [path.resolve('./tests/test.js')] }) ``` ```cjs -const { tap, run } = require('node:test/reporters'); -const process = require('process'); +const { tap } = require('node:test/reporters'); +const { run } = require('node:test'); const path = require('path'); run({ files: [path.resolve('./tests/test.js')] }) From e37742095be45b40f8adb14dd33b3072eabede13 Mon Sep 17 00:00:00 2001 From: Oshri Asulin <114335827+OshriAsulin@users.noreply.github.com> Date: Wed, 6 Sep 2023 14:08:56 +0300 Subject: [PATCH 4/4] Update import and require statements to use 'node:path' In this commit, I update import and require statements throughout the codebase to use 'node:path' instead of 'path'. --- doc/api/test.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index cff6e44ff06f42..cbc7083bbbd0ec 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -910,7 +910,7 @@ changes: import { tap } from 'node:test/reporters'; import { run } from 'node:test'; import process from 'node:process'; -import path from 'path'; +import path from 'node:path'; run({ files: [path.resolve('./tests/test.js')] }) .compose(tap) @@ -920,7 +920,7 @@ run({ files: [path.resolve('./tests/test.js')] }) ```cjs const { tap } = require('node:test/reporters'); const { run } = require('node:test'); -const path = require('path'); +const path = require('node:path'); run({ files: [path.resolve('./tests/test.js')] }) .compose(tap)