mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Propagate errors when testing
Testing with Mocha requires errors raised within flows to propagate to the test runner, not getting swallowed by Node. This commit tests whether Mocha's global functions exist and, if they do, propagates exceptions that are raised there.
This commit is contained in:
parent
e48607c743
commit
c25ada8dcb
@ -41,6 +41,7 @@
|
||||
"cors": "2.8.5",
|
||||
"cronosjs": "1.7.1",
|
||||
"denque": "2.1.0",
|
||||
"detect-mocha": "^0.1.0",
|
||||
"express": "4.21.1",
|
||||
"express-session": "1.18.1",
|
||||
"form-data": "4.0.0",
|
||||
|
@ -21,6 +21,7 @@ const flowUtil = require("./util");
|
||||
const context = require('../nodes/context');
|
||||
const hooks = require("@node-red/util").hooks;
|
||||
const credentials = require("../nodes/credentials");
|
||||
const detectMocha = require("detect-mocha");
|
||||
|
||||
let Subflow;
|
||||
let Log;
|
||||
@ -804,6 +805,9 @@ function deliverMessageToDestination(sendEvent) {
|
||||
} catch(err) {
|
||||
Log.error(`Error delivering message to node:${sendEvent.destination.node._path} [${sendEvent.destination.node.type}]`)
|
||||
Log.error(err.stack)
|
||||
if (detectMocha()) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ var redUtil = require("@node-red/util").util;
|
||||
var Log = require("@node-red/util").log;
|
||||
var context = require("./context");
|
||||
var flows = require("../flows");
|
||||
var detectMocha = require("detect-mocha");
|
||||
const hooks = require("@node-red/util").hooks;
|
||||
|
||||
|
||||
@ -218,6 +219,9 @@ Node.prototype._emitInput = function(arg) {
|
||||
);
|
||||
} catch(err) {
|
||||
node.error(err,arg);
|
||||
if (detectMocha()) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
} else if (node._inputCallbacks) {
|
||||
// Multiple callbacks registered. Call each one, tracking eventual completion
|
||||
|
Loading…
x
Reference in New Issue
Block a user