How to use the chimp.server function in chimp

To help you get started, we’ve selected a few chimp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheBrainFamily / chimpy / src / __tests__ / session-manager-spec.js View on Github external
it('should reuse a session if one has already started in server mode', function () {

      var wd = require('xolvio-sync-webdriverio');
      var SessionManager = require('../lib/session-manager');

      process.env['chimp.server'] = true;
      var browser = {_original: {requestHandler: {sessionID: 'some-id'}}};
      wd.remote = jest.genMockFn().mockReturnValue(browser);

      var sessionManager = new SessionManager({port: 1234, browser: 'something'});

      var sessions = [{id: 'session-id'}];
      sessionManager._getWebdriverSessions = jest.genMockFn().mockImplementation(function (callback) {
        callback(null, sessions);
      });
      sessionManager._waitForConnection = jest.genMockFn().mockImpl(function (browser, callback) {
        callback();
      });

      var options = {some: 'options'};
      var callback = jest.genMockFn();
      sessionManager.remote(options, callback);
github TheBrainFamily / chimpy / src / lib / session-manager.js View on Github external
SessionManager.prototype.killCurrentSession = function (callback) {


  if (this.options.browser === 'phantomjs') {
    log.debug('[chimp][session-manager] browser is phantomjs, not killing session');
    callback();
    return;
  }

  if (booleanHelper.isTruthy(process.env['chimp.noSessionReuse'])) {
    log.debug('[chimp][session-manager] noSessionReuse is true, , not killing session');
    callback();
    return;
  }

  if ((parseBoolean(process.env['chimp.watch']) || parseBoolean(process.env['chimp.server']))
    && !parseBoolean(process.env['forceSessionKill'])) {
    log.debug('[chimp][session-manager] watch / server mode are true, not killing session');
    callback();
    return;
  }


  var wdHubSession = 'http://' + this.options.host + ':' + this.options.port + '/wd/hub/session';

  this._getWebdriverSessions(function (err, sessions) {

    if (sessions && sessions.length) {
      sessions.forEach(function (session) {
        var sessionId = session.id;
        log.debug('[chimp][session-manager]', 'deleting wd session', sessionId);
github TheBrainFamily / chimpy / dist / lib / session-manager.js View on Github external
SessionManager.prototype.killCurrentSession = function (callback) {

  if (this.options.browser === 'phantomjs') {
    log.debug('[chimp][session-manager] browser is phantomjs, not killing session');
    callback();
    return;
  }

  if (!process.env['chimp.noSessionReuse']) {
    log.debug('[chimp][session-manager] noSessionReuse is true, , not killing session');
    callback();
    return;
  }

  if ((parseBoolean(process.env['chimp.watch']) || parseBoolean(process.env['chimp.server'])) && !parseBoolean(process.env['forceSessionKill'])) {
    log.debug('[chimp][session-manager] watch / server mode are true, not killing session');
    callback();
    return;
  }

  var wdHubSession = 'http://' + this.options.host + ':' + this.options.port + '/wd/hub/session';

  this._getWebdriverSessions(function (err, sessions) {

    if (sessions.length) {
      sessions.forEach(function (session) {
        var sessionId = session.id;
        log.debug('[chimp][session-manager]', 'deleting wd session', sessionId);

        request.del(wdHubSession + '/' + sessionId, function (error, response, body) {
          if (!error && response.statusCode == 200) {
github TheBrainFamily / chimpy / src / lib / session-manager.js View on Github external
function decideReuse() {

    if (self.options.browser === 'phantomjs') {
      log.debug('[chimp][session-manager] browser is phantomjs, not reusing a session');
      callback(null, browser);
      return;
    }

    if (booleanHelper.isTruthy(process.env['chimp.noSessionReuse'])) {
      log.debug('[chimp][session-manager] noSessionReuse is true, not reusing a session');
      callback(null, browser);
      return;
    }

    if (booleanHelper.isFalsey(process.env['chimp.watch']) && booleanHelper.isFalsey(process.env['chimp.server'])) {
      log.debug('[chimp][session-manager] watch mode is false, not reusing a session');
      callback(null, browser);
      return;
    }

    self._getWebdriverSessions(function (err, sessions) {
      if (err) {
        callback(err);
        return;
      }
      if (sessions.length !== 0) {
        log.debug('[chimp][session-manager] Found an open selenium sessions, reusing session', sessions[0].id);
        browser._original.requestHandler.sessionID = sessions[0].id;
      } else {
        log.debug('[chimp][session-manager] Did not find any open selenium sessions, not reusing a session');
      }
github TheBrainFamily / chimpy / dist / lib / session-manager.js View on Github external
function decideReuse() {

    if (self.options.browser === 'phantomjs') {
      log.debug('[chimp][session-manager] browser is phantomjs, not reusing a session');
      callback(null, browser);
      return;
    }

    if (booleanHelper.isTruthy(process.env['chimp.noSessionReuse'])) {
      log.debug('[chimp][session-manager] noSessionReuse is true, not reusing a session');
      callback(null, browser);
      return;
    }

    if (booleanHelper.isFalsey(process.env['chimp.watch']) && booleanHelper.isFalsey(process.env['chimp.server'])) {
      log.debug('[chimp][session-manager] watch mode is false, not reusing a session');
      callback(null, browser);
      return;
    }

    self._getWebdriverSessions(function (err, sessions) {
      if (err) {
        callback(err);
        return;
      }
      if (sessions.length !== 0) {
        log.debug('[chimp][session-manager] Found an open selenium sessions, reusing session', sessions[0].id);
        browser._original.requestHandler.sessionID = sessions[0].id;
      } else {
        log.debug('[chimp][session-manager] Did not find any open selenium sessions, not reusing a session');
      }