@@ -57,6 +57,11 @@ function findRuntimePath() {
5757 return path . join ( dirpath , pkg . main ) ;
5858 } catch ( ignored ) { }
5959 }
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 ) { }
6065}
6166
6267
@@ -122,6 +127,14 @@ class NodeTestHelper extends EventEmitter {
122127 this . _NodePrototype = require ( path . join ( prefix , '@node-red/runtime/lib/nodes/Node' ) ) . prototype ;
123128 this . _settings = RED . settings ;
124129 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+
125138 }
126139 } catch ( ignored ) {
127140 console . log ( ignored ) ;
@@ -240,13 +253,24 @@ class NodeTestHelper extends EventEmitter {
240253 } ) ;
241254 }
242255
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 ] ;
249267 }
268+ testNode . forEach ( fn => {
269+ if ( ! preloadedCoreModules . has ( fn ) ) {
270+ fn ( red ) ;
271+ }
272+ } ) ;
273+
250274 return redNodes . loadFlows ( )
251275 . then ( ( ) => {
252276 redNodes . startFlows ( ) ;
0 commit comments