Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details →
Socket
Book a DemoInstallSign in
Socket

protractor-parallel-retrier

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protractor-parallel-retrier

đź›  Development in progress, beta version

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

protractor-parallel-retrier

đź›  Development in progress, beta version

npm downloads

This library is a wrapper around process-rerun

The purpose of this library is - build simple and flexible interface for protractor framework parallel execution with rerun (on fail) possibility

Usage and Example


Documentation

usage

const {buildExecutor} = require('protractor-parallel-retrier');

executeAsQueue();
async function executeAsQueue() {

  const testCaseRegPattern = /(?<=it\(').+(?=')/ig;
  const cwd = process.cwd();

  const result = await buildExecutor(resolve(cwd, './protractor.conf.js'), resolve(cwd, './built/specs'))
    .asQueue(testCaseRegPattern, ['test case it name 1', 'test case it name 2', 'test case it name 3'])
    .command({'--process-argument': 'process-argument-value'}, {ENV_VARIABLE: 'en-varialbe-value'})
    .executor({attemptsCount: 2, maxThreads: 1, logLevel: 'VERBOSE', longestProcessTime: 60 * 1000, pollTime: 100})
    .execute();

  console.log(result);
  if(result.retriable.length || result.notRetriable.length) {
    process.exit(1);
  }
}

executeOnlyRequiredCases();
async function executeAsQueue() {

  const testCaseRegPattern = /(?<=it\(').+(?=')/ig;
  const cwd = process.cwd();

  const result = await buildExecutor(resolve(cwd, './protractor.conf.js'), resolve(cwd, './built/specs'))
    .asQueue(testCaseRegPattern, ['test case it name 1', 'test case it name 2', 'test case it name 3'])
    .command({'--process-argument': 'process-argument-value'}, {ENV_VARIABLE: 'en-varialbe-value'})
    .executor({attemptsCount: 2, maxThreads: 10, logLevel: 'VERBOSE', longestProcessTime: 60 * 1000, pollTime: 100})
    .execute();

  console.log(result);
  if(result.retriable.length || result.notRetriable.length) {
    process.exit(1);
  }
}

executeByFile();
async function executeByFile() {
  const cwd = process.cwd();
  const result = await buildExecutor(resolve(cwd, './protractor.conf.js'), resolve(cwd, './built/specs'))
    .byFile()
    .command({'--process-argument': 'process-argument-value'}, {ENV_VARIABLE: 'en-varialbe-value'})
    .executor({attemptsCount: 2, maxThreads: 5, logLevel: 'VERBOSE', longestProcessTime: 60 * 1000, pollTime: 100})
    .execute();

  console.log(result);
  if(result.retriable.length || result.notRetriable.length) {
    process.exit(1);
  }
}


executeByIt();
async function executeByIt() {
  const cwd = process.cwd();
  const testCaseRegPattern = /(?<=it\(').+(?=')/ig;
  const result = await buildExecutor(resolve(cwd, './protractor.conf.js'), resolve(cwd, './built/specs'))
    .byIt(testCaseRegPattern)
    .command({'--process-argument': 'process-argument-value'}, {ENV_VARIABLE: 'en-varialbe-value'})
    .executor({attemptsCount: 2, maxThreads: 2, logLevel: 'VERBOSE', longestProcessTime: 60 * 1000, pollTime: 100})
    .execute();

  console.log(result);
  if(result.retriable.length || result.notRetriable.length) {
    process.exit(1);
  }
}

Documentation



buildExecutor

buildExecutor('./path/to/protractor.conf.js', './path/to/specs/folder')

argumentsdescription
pathToProtractorConfigFileType: string
Path to protractor config file
pathToSpecFolderOrSpecsFilesListType: string or string[]
Path to specs folder, or list (array) with specs files path;

returns {byIt: function; byFile: function; asQueue: function}

byIt

buildExecutor(...args).byIt(/(?<=it\(').+(?=')/ig) or .byIt()

argumentsdescription
itPatternType: OPTIONAL RegEx
RegEx for it title. example it('test item'); -> itRegEx = /(?<=it(').+(?=')/ig;
in case of undefined library will define itPattern based on first symbol in it title;
pathToSpecFolderOrSpecsFilesListType: string or string[]
Path to specs folder, or list (array) with specs files path;

returns {command: function}



byFile

buildExecutor(...args).byFile()

no arguments here

returns {command: function}



asQueue

buildExecutor(...args).asQueue(/(?<=it\(').+(?=')/ig, ['test1', 'test2', 'test 10']) or buildExecutor(...args).asQueue(['test1', 'test2', 'test 10'])

argumentsdescription
itPatternType: OPTIONAL RegEx
RegEx for it title. example it('test item'); -> itRegEx = /(?<=it(').+(?=')/ig;
in case of undefined library will define itPattern based on first symbol in it title;
casesListType: string[]
List with tests what should be executed one by on can be first argument, because itPattern is an optional

returns {command: function}



command

buildExecutor(...args).asQueue(...args1).command({'--test': 'test'}, {ENV: 'test'}) or buildExecutor(...args).asQueue(...args1).command()

argumentsdescription
processArgsType: undefined or null or {[prop: string]: string}
Object with required process argumentss, use format prop name with - or --, example '--prop' or '-p'
processEnvVarsType: undefined or null or {[prop: string]: string}
Object with required process env variables, use format prop name upper snake_case, LOG_LEVEL

returns {executor: function}



executor

buildExecutor(...args).asQueue(...args1).command().executor({maxThreads: 1, attemptsCount: 2, logLevel: 'ERROR'})

argumentsdescription
buildOptsType: object
Options for executor
buildOpts.maxThreadsType: number,
How many threads can be executed in same time
Default threads count is 5
buildOpts.attemptsCountType: number,
How many times can we try to execute command for success result in next cycle will be executed only faild command, success commands will not be reexecuted
Default attempts count is 2
buildOpts.pollTimeType: number ,
Period for recheck about free thread
Default is 1 second
buildOpts.logLevelType: string, one of 'ERROR', 'WARN', 'INFO', 'VERBOSE',
ERROR - only errors, WARN - errors and warnings, INFO - errors, warnings and information, VERBOSE - full logging
Default is 'ERROR'
buildOpts.currentExecutionVariableType: string, will be execution variable with execution index for every cycle will be ++
buildOpts.everyCycleCallbackType: function,
Optional. everyCycleCallback will be executed after cycle, before next execution cycle.
Default is false
buildOpts.processResultAnalyzerType: function,
Optional. processResultAnalyzer is a function where arguments are original command, execution stack trace and notRetriable array processResultAnalyzer should return a new command what will be executed in next cycle or null - if satisfactory result
buildOpts.longestProcessTimeType: number,
In case if command execution time is longer than longest Process Time - executor will kill it automatically and will try to execute this command again.
Default time is 45 seconds

returns {execute: async function}



execute

buildExecutor(...args).asQueue(...args1).command().executor(...args2).execute()

no arguments here

returns {retriable: string[]; notRetriable: string[]}

Keywords

flaky

FAQs

Package last updated on 22 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts