@@ -57,6 +57,11 @@ function findRuntimePath() {
57
57
return path . join ( dirpath , pkg . main ) ;
58
58
} catch ( ignored ) { }
59
59
}
60
+ // case 4: NR & NRNTH are git repos sat alongside each other
61
+ try {
62
+ const nrpkg = require ( "../node-red/package.json" ) ;
63
+ return "../node-red/packages/node_modules/node-red"
64
+ } catch ( ignored ) { }
60
65
}
61
66
62
67
@@ -122,6 +127,14 @@ class NodeTestHelper extends EventEmitter {
122
127
this . _NodePrototype = require ( path . join ( prefix , '@node-red/runtime/lib/nodes/Node' ) ) . prototype ;
123
128
this . _settings = RED . settings ;
124
129
this . _events = RED . runtime . events ;
130
+
131
+ this . _nodeModules = {
132
+ 'catch' : require ( path . join ( prefix , '@node-red/nodes/core/common/25-catch.js' ) ) ,
133
+ 'status' : require ( path . join ( prefix , '@node-red/nodes/core/common/25-status.js' ) ) ,
134
+ 'complete' : require ( path . join ( prefix , '@node-red/nodes/core/common/24-complete.js' ) )
135
+ }
136
+
137
+
125
138
}
126
139
} catch ( ignored ) {
127
140
console . log ( ignored ) ;
@@ -240,13 +253,24 @@ class NodeTestHelper extends EventEmitter {
240
253
} ) ;
241
254
}
242
255
243
- if ( Array . isArray ( testNode ) ) {
244
- testNode . forEach ( fn => {
245
- fn ( red ) ;
246
- } ) ;
247
- } else {
248
- testNode ( red ) ;
256
+ let preloadedCoreModules = new Set ( ) ;
257
+ testFlow . forEach ( n => {
258
+ if ( this . _nodeModules . hasOwnProperty ( n . type ) ) {
259
+ // Go find the 'real' core node module and load it...
260
+ this . _nodeModules [ n . type ] ( red ) ;
261
+ preloadedCoreModules . add ( this . _nodeModules [ n . type ] ) ;
262
+ }
263
+ } )
264
+
265
+ if ( ! Array . isArray ( testNode ) ) {
266
+ testNode = [ testNode ] ;
249
267
}
268
+ testNode . forEach ( fn => {
269
+ if ( ! preloadedCoreModules . has ( fn ) ) {
270
+ fn ( red ) ;
271
+ }
272
+ } ) ;
273
+
250
274
return redNodes . loadFlows ( )
251
275
. then ( ( ) => {
252
276
redNodes . startFlows ( ) ;
0 commit comments