This repository was archived by the owner on Jul 18, 2025. It is now read-only.
Commit 3f36d58
Peter Somogyvari
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>1 parent db3fe87 commit 3f36d58
3 files changed
Lines changed: 15 additions & 4 deletions
File tree
- packages
- cactus-cmd-api-server/src/test/typescript/integration
- cactus-test-cmd-api-server/src/test/typescript/integration
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | | - | |
| 147 | + | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| |||
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | | - | |
| 224 | + | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
0 commit comments