无法运行 json rpc 测试用例自动化的 nodejs 脚本



我正在尝试运行为json rpc测试用例自动化编写的nodejs脚本。但是,我不断收到错误:

npm run testresourcesnv-jsonrpc-testspingServer.spec.js
error missing script: testresourcesnv-jsonrpc-testspingServer.spec.js
verbose exit [ 1, true ]/>
var rpc = require('node-json-rpc');
var options = {
// int port of rpc server
port: 8080,
// string domain name or ip of rpc server, default '127.0.0.1'
host: '127.0.0.1',
// string with default path, default '/'
path: 'https://',
// boolean false to turn rpc checks off, default true
strict: true
};
// Create a server object with options
var client = new rpc.Client(options);
client.call(
{"jsonrpc": "2.0", "method": "Ping", "params": {classname: 'NServer'}, 
"id": 1},
function (err, res) {
// Check whether it worked and capture the response and error
if (err) { console.log(err); }
else { console.log(res); }
}
);

期望:

客户端使用"Ping"发送请求,并从服务器响应接收"Pong"。

你似乎混淆了npm runnode

npm run旨在执行package.json
中声明的脚本 node可以直接执行您给出的文件中的脚本

运行这个应该可以工作

node testresourcesnv-jsonrpc-testspingServer.spec.js

最新更新