src/test/testClientSupport.js
/**
   * @summary **Connects to a mMeddle server as a mochatests client**
   * @description
   * This routine connects to a mMeddle server as a client named 'mochatests',
   * and populates mm with the most useful objects to do client testing.
   * Note that once connected, this will only attempt to reconnect if the
   * connection is lost.
   * @example:
   *     mm.test.client.cs       // the current ClientSession
   *     mm.test.client.mmc      // the current MMeddleClient
   *     mm.test.client.mConsole // the current console (Mock)
   *     mm.test.client.cmds     // the current CliCommands
   * @returns a promise that resolves when connected.
   * @alias module:test/testClientSupport.mochaTestConnect
   */
@summary **Connects to a mMeddle server as a mochatests client
@description
This routine connects to a mMeddle server as a client named 'mochatests',
and populates mm with the most useful objects to do client testing.
Note that once connected, this will only attempt to reconnect if the
connection is lost.
@summary ** Connects to a mMeddle server as a mochatests client @description This routine connects to a mMeddle server as a client named ' mochatests ' and populates mm with the most useful objects to do client testing . Note that once connected this will only attempt to reconnect if the connection is lost .
function mochaTestConnect() {
    try {
      mochaTestWorkspace();
      if (connectedP) {
        connectedTimer.reset(); 
        return connectedP; 
      }
      connectedTimer = new EggTimer(MAX_TEST_TIMEOUT_SEC * 1000);
      connectedTimer.onDing(function () {
        if (mm.config.inNode) {
          mm.log('----- Shutdown server connection for tests.');      
          mm.test.client.mConsole.close();
        }
      });
      mm.log('- Connect to the test Server');
      mm.test.debugon = true;
      var mockSock = mm.util.ifEnvOption('MOCKSOCK') || mm.config.mocksock;
      if (mockSock) {
        mm.socketServer.io = new mm.mockSock.Server();
        mm.socketClient.io = new mm.mockSock.Client(mm.socketServer.io);
        mockMeddleServer();
      }
      connectedP = mm.test.client.mmc.connectWorkspace()
      .then(function() {
        mm.log('- Connected to server {0}', mm.test.client.mmc.host);
        mm.test.client.cs.emitLogMessage(
            mm.test.client.cs.appName + ' connected!');
      });
      return connectedP;
    }
    catch (e) {
        mm.log.error('Test Client Setup failed.', e.stack);
    }
  }
function mochaTestConnect ( ) { try { mochaTestWorkspace ( ) ; if ( connectedP ) { connectedTimer . reset ( ) ; return connectedP ; } connectedTimer = new EggTimer ( MAX_TEST_TIMEOUT_SEC * 1000 ) ; connectedTimer . onDing ( function ( ) { if ( mm . config . inNode ) { mm . log ( '----- Shutdown server connection for tests.' ) ; mm . test . client . mConsole . close ( ) ; } } ) ; mm . log ( '- Connect to the test Server' ) ; mm . test . debugon = true ; var mockSock = mm . util . ifEnvOption ( 'MOCKSOCK' ) || mm . config . mocksock ; if ( mockSock ) { mm . socketServer . io = new mm . mockSock . Server ( ) ; mm . socketClient . io = new mm . mockSock . Client ( mm . socketServer . io ) ; mockMeddleServer ( ) ; } connectedP = mm . test . client . mmc . connectWorkspace ( ) . then ( function ( ) { mm . log ( '- Connected to server {0}' , mm . test . client . mmc . host ) ; mm . test . client . cs . emitLogMessage ( mm . test . client . cs . appName + ' connected!' ) ; } ) ; return connectedP ; } catch ( e ) { mm . log . error ( 'Test Client Setup failed.' , e . stack ) ; } }
@summary **Connects to a mMeddle server as a mochatests client
 @description
 This routine connects to a mMeddle server as a client named 'mochatests',
 and populates mm with the most useful objects to do client testing.
@summary ** Connects to a mMeddle server as a mochatests client @description This routine connects to a mMeddle server as a client named ' mochatests ' and populates mm with the most useful objects to do client testing .
// Once the connection has succeeded or failed, we never need to // look at it again. // Live for a bit longer. // All is well or terrible. //process.exit(); // Do the actual connection.