mocha 从 node-red 更改流文件路径
mocha change Flow file path from node-red
我在使用 mocha 对 node-red 节点实施单元测试时遇到问题。
如果我 运行 我使用“$ sudo mocha -t 3000” node-red 的测试无法加载 flow_user.json。因为 mocha 中的选项“3000”被设置为 'Flow file:' 路径中的目录。
node-opcua-client
✓ copy testfile 'flow/flows_user' (1509ms)
✓ run Node-Red (1856ms)
Welcome to Node-RED
===================
22 Sep 14:13:03 - [info] Node-RED version: v0.11.1
22 Sep 14:13:03 - [info] Node.js version: v0.12.3
22 Sep 14:13:03 - [info] Loading palette nodes
Warning : using memcpy : OK
FAST: using node-expat
22 Sep 14:13:04 - [warn] ------------------------------------------
22 Sep 14:13:04 - [warn] Failed to register 1 node type
22 Sep 14:13:04 - [warn] Run with -v for details
22 Sep 14:13:04 - [warn] ------------------------------------------
22 Sep 14:13:04 - [info] Settings file : /usr/local/lib/node_modules/node-red/settings.js
22 Sep 14:13:04 - [info] User directory : /home/user/.node-red
22 Sep 14:13:04 - [info] Flows file : /home/user/.node-red/30000
22 Sep 14:13:04 - [info] Server now running at http://127.0.0.1:1880/
22 Sep 14:13:04 - [info] Creating new flow file
22 Sep 14:13:04 - [info] Starting flows
22 Sep 14:13:04 - [info] Started flows
在'test.js'中我用
打开node-red
RED = require ('/usr/local/lib/node_modules/node-red/red.js');
我错了吗?
感谢您的帮助
您需要在此处查看网站上的嵌入 Node-RED 文档:http://nodered.org/docs/embedding.html
但基本上你应该要求 node-red 然后创建一个设置对象来传入
var RED = require('node-red');
...
var server = http.createServer(app);
...
var settings = {
httpAdminRoot:"/red",
httpNodeRoot: "/api",
userDir:"/home/nol/.nodered/",
flowFile: "flow_user.json",
functionGlobalContext: { } // enables global context
};
...
RED.init(server,settings);
我在使用 mocha 对 node-red 节点实施单元测试时遇到问题。
如果我 运行 我使用“$ sudo mocha -t 3000” node-red 的测试无法加载 flow_user.json。因为 mocha 中的选项“3000”被设置为 'Flow file:' 路径中的目录。
node-opcua-client
✓ copy testfile 'flow/flows_user' (1509ms)
✓ run Node-Red (1856ms)
Welcome to Node-RED
===================
22 Sep 14:13:03 - [info] Node-RED version: v0.11.1
22 Sep 14:13:03 - [info] Node.js version: v0.12.3
22 Sep 14:13:03 - [info] Loading palette nodes
Warning : using memcpy : OK
FAST: using node-expat
22 Sep 14:13:04 - [warn] ------------------------------------------
22 Sep 14:13:04 - [warn] Failed to register 1 node type
22 Sep 14:13:04 - [warn] Run with -v for details
22 Sep 14:13:04 - [warn] ------------------------------------------
22 Sep 14:13:04 - [info] Settings file : /usr/local/lib/node_modules/node-red/settings.js
22 Sep 14:13:04 - [info] User directory : /home/user/.node-red
22 Sep 14:13:04 - [info] Flows file : /home/user/.node-red/30000
22 Sep 14:13:04 - [info] Server now running at http://127.0.0.1:1880/
22 Sep 14:13:04 - [info] Creating new flow file
22 Sep 14:13:04 - [info] Starting flows
22 Sep 14:13:04 - [info] Started flows
在'test.js'中我用
打开node-redRED = require ('/usr/local/lib/node_modules/node-red/red.js');
我错了吗?
感谢您的帮助
您需要在此处查看网站上的嵌入 Node-RED 文档:http://nodered.org/docs/embedding.html
但基本上你应该要求 node-red 然后创建一个设置对象来传入
var RED = require('node-red');
...
var server = http.createServer(app);
...
var settings = {
httpAdminRoot:"/red",
httpNodeRoot: "/api",
userDir:"/home/nol/.nodered/",
flowFile: "flow_user.json",
functionGlobalContext: { } // enables global context
};
...
RED.init(server,settings);