老实说,我对node和npm世界有些陌生。我有一个简单的任务将普通.json
文件转换为JunitXML
。下面是我的.json文件的示例
{
"version" : "1.5.1",
"seed" : "74bf0b8b407df28b82f05861e9085b91",
"options" : {
"audit" : {
"parameter_values" : true,
"exclude_vector_patterns" : [],
"include_vector_patterns" : [],
"link_templates" : [],
"forms" : true,
"jsons" : true,
"links" : true,
"ui_forms" : true,
"ui_inputs" : true,
"xmls" : true
},
"browser_cluster" : {
"local_storage" : {},
"wait_for_elements" : {},
"pool_size" : 3,
"job_timeout" : 90,
"worker_time_to_live" : 100,
"ignore_images" : true,
"screen_width" : 1600,
"screen_height" : 1200
},
}
}
我在网上找到了this npm package。我做了所有文档建议的事情:
save-dev
的身份进行安装,因为我希望此包可从文件系统上的任何位置使用(Windows 10)但是,第二个命令失败并显示错误消息
TypeError: Cannot read property 'start' of undefined
at Object.convertJson (C:\JohnDoe\AppData\Roaming\npm\node_modules\jsonjunit\lib\jsonjunit.js:35:61)
at Object.<anonymous> (C:\JohnDoe\AppData\Roaming\npm\node_modules\jsonjunit\index.js:33:23)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:
如果我执行此命令(只需将.json文件添加到路径中)
/my_file_system/node_modules/.bin/jsonjunit --json C:\ JohnDoe \ JsonFileIsHere \ report.json --junit C:\ JohnDoe \ JunitFileIsHere
我得到了不同类型的错误消息
Error: ENOTDIR: not a directory, scandir 'C:\JohnDoe\JsonFileIsHere\report.json'
at Object.fs.readdirSync (fs.js:921:18)
at Object.<anonymous> (C:\JohnDoe\AppData\Roaming\npm\node_modules\jsonjunit\index.js:26:24)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
执行此命令(使用双引号)
/my_file_system/node_modules/.bin/jsonjunit --json “ C:\ JohnDoe \ JsonFileIsHere \” --junit“ C:\ JohnDoe \ JunitFileIsHere”
导致另一个错误消息You must specify both JSON and JUNIT path!
,因此我认为双引号无济于事。
我也尝试用单引号
/my_file_system/node_modules/.bin/jsonjunit --json 'C:\ JohnDoe \ JsonFileIsHere \'--junit'C:\ JohnDoe \ JunitFileIsHere'
...而且,正如我所料,另一个有趣的错误消息
Error: ENOENT: no such file or directory, mkdir 'C:\JohnDoe\node_modules\jsonjunit\'C:\JohnDoe\JunitFileIsHere'
at Object.fs.mkdirSync (fs.js:902:18)
at Object.<anonymous> (C:\JohnDoe\AppData\Roaming\npm\node_modules\jsonjunit\index.js:23:12)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
有人成功实现了该库吗?我确定我会丢失其中的一小部分以使其正常工作。感谢您的建议。