Skip to content

Using Jasmine -- Retry runs all the Test cases and not only the failed test cases. #89

@ankushpoly13

Description

@ankushpoly13

Using Jasmine -- Retry runs all the Test cases and not only the failed test cases.

Please refer below configuration and testfile.

Configuration File :

import { Config, browser } from "protractor";
declare const allure: any;
import protractor = require('protractor')
import { createmodules } from "./pageObjects/createmoduleElements";
import * as Cred from "./jsonfiles/credentials.json";
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
import * as fs from 'fs';
var retry = require('protractor-retry').retry;

export let config: Config = {
  allScriptsTimeout: 400000,
  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      w3c: false,
      // args: ['--headless', '--window-size=1920x1280'],
      args: ['--window-size=1920x1280'],
    },

  },


  onCleanUp: function (results) {
    retry.onCleanUp(results);
  },

  onPrepare: function () {

    //retry function
    retry.onPrepare();
   
    jasmine.getEnv().addReporter(
      new SpecReporter({
        suite: {
          displayNumber: true // display each suite number (hierarchical)
        },
        spec: {
          displayPending: false, // display each pending spec
          displayDuration: true // display each spec duration
        },
        summary: {
          displaySuccesses: true, // display summary of all successes after execution
          displayFailed: true, // display summary of all failures after execution
          displayPending: true // display summary of all pending specs after execution
        }
      })
    );


    var AllureReporter = require('jasmine-allure-reporter');
    jasmine.getEnv().addReporter(new AllureReporter());
    jasmine.getEnv().afterEach(function (done) {
      browser.takeScreenshot().then(function (png) {
        allure.createAttachment('Screenshot', function () {
          return Buffer.from(png, 'base64')
        }, 'image/png')();
        done();
      })
    });

  },

  afterLaunch: function () {
    return retry.afterLaunch(2); // number of retries ( default is 2 )
  },

  specs: ['./Testsuite/clients.js'],

  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
    defaultTimeoutInterval: 400000,
  }
};

Test File


describe('Client Module', function () {
  it('Client 1', async () => { 
some code . . . . . .
. . . . . .
. . . . . .

  })
  it('Client 2', async () => {
some code . . . . . .
. . . . . .
. . . . . .

  })
})

describe('Client Module', function () {
  it('Candidates  1', async () => {
          some code . . . . . .
          . . . . . .
          . . . . . .

  })
  it('Candidates  2', async () => {
        some code . . . . . .
        . . . . . .
        . . . . . .

  })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions