How to use the chimp.noSessionReuse 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('starts a new session when noSessionReuse is true when a session exists', function () {

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

      wd.remote = jest.genMockFn().
        mockReturnValueOnce('return from remote1').
        mockReturnValueOnce('return from remote2');
      var sessionManager = new SessionManager({port: 1234, browser: 'something'});

      sessionManager._waitForConnection = jest.genMockFn().mockImpl(function (browser, callback) {
        callback();
      });

      var options = {some: 'options'};
      process.env['chimp.noSessionReuse'] = true;
      var callback = jest.genMockFn();
      sessionManager.remote(options, callback);
      sessionManager.remote(options, callback);

      expect(callback.mock.calls[0][1]).toBe('return from remote1');
      expect(callback.mock.calls[1][1]).toBe('return from remote2');
      expect(callback.mock.calls[1][1].requestHandler).toBeFalsy();
      expect(callback.mock.calls[1][1].requestHandler).toBeFalsy();

      expect(wd.remote.mock.calls.length).toBe(2);
      expect(wd.remote.mock.calls[0][0]).toBe(options);
      expect(wd.remote.mock.calls[1][0]).toBe(options);

    });
github TheBrainFamily / chimpy / src / __tests__ / session-manager-spec.js View on Github external
beforeEach(function () {
      delete process.env['chimp.noSessionReuse'];
      delete process.env['chimp.watch'];
    });
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) {
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) {
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;
      }
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;
      }