title: How to retry failed test specs in protractor jasmine
body: <p>I am trying to use protractor-retry mechanism to run my protractor e2e tests.
  I have installed Protractor-retry package and added required things in conf.js file as below:</p>
  
  <pre><code>var PropertiesReader = require('properties-reader');
  var properties = PropertiesReader('config.properties');
  var retry = require('protractor-retry').retry;
  exports.config = {
  
  plugins: [{
      package: 'jasmine2-protractor-utils',
      disableHTMLReport: false,
      disableScreenshot: false,
      //screenshotPath: './reports/screenshots',
      screenshotPath: './ExecutionResults/reports/screenshots',
      screenshotOnExpectFailure: true,
      screenshotOnSpecFailure: true,
      clearFoldersBeforeTest: true,
      htmlReportDir: './reports/htmlReports',
      failTestOnErrorLog: {
          failTestOnErrorLogLevel: 1100,
          excludeKeywords: ['keyword1', 'keyword2']
      }
  }],
  directConnect: true,
  // Capabilities to be passed to the webdriver instance.
  multiCapabilities: [
      {
          'browserName': properties.get('browserName'),
      }],
  
      onCleanUp: function(results) {
          retry.onCleanUp(results);
      },
  suites: {
          test: '../test_spec/smoke/cards/test.js'
  },
  
  // Options to be passed to Jasmine.
  allScriptsTimeout: properties.get('allscriptTimeOutSeconds'),
  getPageTimeout: properties.get('pageTimeOut'),
  jasmineNodeOpts: {
      defaultTimeoutInterval: 2000000
  },
  onPrepare: function () {
      retry.onPrepare();
      var jasmineReporters = require('jasmine-reporters');
      var width = 1400;
      var height = 1000;
      browser.driver.manage().window().maximize();
      useAllAngular2AppRoots: true,
      browser.driver.get(properties.get('envUrl'),);
      browser.driver.manage().timeouts().implicitlyWait(10000);
  
      var AllureReporter = require('jasmine-allure-reporter');
      jasmine.getEnv().addReporter(new AllureReporter({
          allureReport: {
              resultsDir: 'allure-results'
          }
      }));
  
      jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
          consolidateAll: true,
          savePath: 'testresults',
          filePrefix: 'xmloutput'
      }));
      var junitReporter = new jasmineReporters.JUnitXmlReporter({
          // setup the output path for the junit reports
          savePath: 'output/',
          consolidateAll: false
      });
      jasmine.getEnv().addReporter(junitReporter);
      return global.browser.getProcessedConfig().then(function (config) { });
  },
  afterLaunch: function() {
      return retry.afterLaunch(2);
   },
  
  onComplete: function () {
      var browserName, browserVersion;
      var capsPromise = browser.getCapabilities();
  
      capsPromise.then(function (caps) {
          browserName = caps.get('browserName');
          browserVersion = caps.get('version');
  
          var HTMLReport = require('protractor-html-reporter');
  
          testConfig = {
              reportTitle: 'Test Execution Report',
              outputPath: './ExecutionResults/reports',
              screenshotPath: './screenshots',
              testBrowser: browserName,
              browserVersion: browserVersion,
              modifiedSuiteName: false,
              screenshotsOnlyOnFailure: true
          };
          browser.sleep(5000)
          new HTMLReport().from('testresults/xmloutput.xml', testConfig);
          browser.close();
      });
  }
  };
  </code></pre>
  
  <p>My test file is as below:</p>
  
  <pre><code>describe("Timesheet_Apply_Approved_Card", function () {
  it ("Retest 1." , function(){
      //browser.get("http://www.google.com")
      //  browser.sleep(3000)
      console.log("test var : "+ testing.label)
      console.log("test " + testing._exitReasonFamilyReason)
         console.log("after test")
      expect("a").toEqual("b")
  })
  
  
  it ("Restest 2." , function(){
      console.log("after test 2")
      expect("a").toEqual("a")
  })
  })
  </code></pre>
  
  <p>But when I run the above test.js file. It does not run the failed test again.It gives below error:</p>
  
  <pre><code>test var : undefined
  test undefined
  inside method undefined
  after test
  Fafter test 2
  .
  
  Failures:
  1) Timesheet_Apply_Approved_Card Retest 1.
  Message:
  Expected 'a' to equal 'b'.
  Stack:
  Error: Failed expectation
      at UserContext.&lt;anonymous&gt; 
  (D:\GIT\altworklife\CARDS\test_spec\smoke\cards\test.js:20:21)
  
  2 specs, 1 failure
  Finished in 0.545 seconds
  
  [17:43:43] I/launcher - 0 instance(s) of WebDriver still running
  [17:43:43] I/launcher - chrome #01 failed 1 test(s)
  [17:43:43] I/launcher - overall: 1 failed spec(s)
  
  
   Re-running tests , attempt :  1
   Re-running the following test files : 
   D:\GIT\altworklife\CARDS\test_spec\smoke\cards\test.js
  
  
  [17:43:43] E/launcher - spawn 
  C:\Users\amit.hada\AppData\Roaming\npm\node_modules\protractor\bin\protractor 
  ENOENT
  [17:43:43] E/launcher - Error: spawn 
  C:\Users\amit.hada\AppData\Roaming\npm\node_modules\protractor\bin\protractor 
  ENOENT
  at _errnoException (util.js:1022:11)
  at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
  at onErrorNT (internal/child_process.js:372:16)
  at _combinedTickCallback (internal/process/next_tick.js:138:11)
  at process._tickCallback (internal/process/next_tick.js:180:9)
  [17:43:43] E/launcher - Process exited with error code 199
  </code></pre>
  
  <p>It prints that it is trying again but than abruptly fails with error as given above.</p>
  
  <p>Any idea, why it is failing without retrying?</p>