GithubHelp home page GithubHelp logo

emaks / process-rerun Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simple-automation-testing/process-rerun

0.0 0.0 0.0 108 KB

Rerun protractor failed tests

License: MIT License

JavaScript 85.78% TypeScript 14.22%

process-rerun's Introduction

What is the problem ? When some process failed we need tool for rerun that process controled times with some params. In common cases we use protractor so next example for protractor

npm downloads

From command line

./node_modules/.bin/process-rerun --protractor --configPath=./protractor.conf.js --specDir=./specs

From js

const { getReruner, getSpecFilesArr } = require('process-rerun')

/*
  @{pathToSpecDirectory} string // './specs'
  @{emptyArr} epmty arr // []
  @{skipFolders} if some folders should be excluded ['folderB','folderB']
  getSpecFilesArr(pathToSpecDirectory, emptyArr, skipFolders) params
*/
const specsArr = getSpecFilesArr('./specs')
// return all files in folder and subFolders
/*
[
  'specs/1.spec.ts',
  'specs/2.spec.ts',
  'specs/3.spec.ts',
  'specs/4.spec.ts',
  'specs/5.spec.ts',
  'specs/6.spec.ts',
  'specs/7.spec.ts',
  'specs/8.spec.ts',
  'specs/9.spec.ts'
]
*/
// now we need commands array
const formCommand = (filePath) => `./node_modules/.bin/protractor  ./protractor.conf.js  --specs ${filePath}`
const commandsArray = specsArr.map(filePath)
/*
[ './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/1.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/2.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/3.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/4.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/5.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/6.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/7.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/8.spec.ts',
  './node_modules/.bin/protractor  ./protractor.conf.js  --specs specs/9.spec.ts' ]
*/

// now we need runner
/*
  getReruner(obj) params
  @{everyCycleCallback} function, will execute after full cycle done, before next cycle
  @{maxSessionCount} number, for example we have hub for 10 browsers, so maxSessionCount equal 10
  @{attemptsCount} number, hom many times will reruned failed processes
  @{stackAnalize} function, if stack trace includes some math this process will not go to rerun scope
*/
const cycleCB = () => console.log('Cycle done')
const stackAnalize = (stack) => !stack.includes('ASSERTION ERROR')

const runner = getReruner({
   everyCycleCallback: cycleCB,
   maxSessionCount: 1,
   attemptsCount: 3,
   stackAnalize: stackAnalize,
   debugProcess: processEnv.DEBUG_PROCESS
 })

getReruner().then((results) => console.log(results))
// return array with failed processes

Note about command re-format functions.

There are two command re-format functions, that you can pass to getReruner.

const formCommanWithOption = (cmd) => {
  return {
    cmd: `${cmd} --someArgument=value --beforeRunFlag`,
    cmdExecutableCB: () => { /* make something specific after command has run */ }
  }
}

const reformatCommand = (cmd) => `${cmd} --someArgument=value --afterFirstRunFlag`

const runner = getReruner({
    formCommanWithOption,
    reformatCommand,
    /* other arguments */
 })

formCommanWithOption - will help you to run your commands on some specific environment, with some specific flags, etc. Also it allows you to execute some callback, after your command has run.

reformatCommand - in another hand, allows you to add some specific options to command after it failed during first execution

process-rerun's People

Contributors

emaks avatar emaksimenko avatar olebon-como avatar potapovdim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.