Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cmd-api-server): fix package.json needs an import assertion - json
Refactored the test cases so that they use the build-in file system libraries of NodeJS to read the file contents of the dynamically pulled in package.json The dynamic import with import type assertion cannot work because we do not yet have the migration to ESM completed and therefore it won't compile if you try to do it like it's supposed to be: ```typescript const { default: data } = await import("./foo.json", { assert: { type: "json" } }); ``` When running the test cases in question it would produce the failure pasted below: ```sh not ok 3 TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///home/runner/work/cacti/cacti/.tmp/test/test-cmd-api-server/ plugin-import-from-github_test/5c711023-7573-4272-aee9-c743f5346ce7/ fad4ca80-c93a-4611-9a68-207c9ad2085e/node_modules/@hyperledger/ cactus-dummy-package/package.json" needs an import assertion of type "json" --- operator: error at: bound call (/home/runner/work/cacti/cacti/node_modules/ tape-promise/node_modules/onetime/index.js:30:12) stack: |- TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///home/runner/work/cacti/cacti/.tmp/test/test-cmd-api-server/ plugin-import-from-github_test/5c711023-7573-4272-aee9-c743f5346ce7/ fad4ca80-c93a-4611-9a68-207c9ad2085e/node_modules/@hyperledger/ cactus-dummy-package/package.json" needs an import assertion of type "json" at new NodeError (node:internal/errors:405:5) at validateAssertions (node:internal/modules/esm/assert:95:15) at defaultLoad (node:internal/modules/esm/load:91:3) at nextLoad (node:internal/modules/esm/loader:163:28) at ESMLoader.load (node:internal/modules/esm/loader:603:26) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22) at new ModuleJob (node:internal/modules/esm/module_job:64:26) at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) at processTicksAndRejections (node:internal/process/task_queues:95:5) ... ``` Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information