Skip to main content

testplane-retry-command

Overview

Use the testplane-retry-command plugin to retry commands at low level.

Install

npm install -D testplane-retry-command

Setup

Add the plugin to the plugins section of the testplane config:

module.exports = {
plugins: {
"testplane-retry-command": {
enabled: true,
rules: [
{
condition: "blank-screenshot",
browsers: ["MicrosoftEdge"],
retryCount: 5,
retryInterval: 120,
},
{
condition: "assert-view-failed",
browsers: ["Chrome"],
retryCount: 1,
retryOnlyFirst: true,
},
],
},

// other Testplane plugins...
},

// other Testplane settings...
};

Description of configuration parameters

ParameterTypeDefault valueDescription
enabledBooleantrueEnable / disable the plugin.
rulesArrayN/AA set of rules according to which commands will be retried. Required parameter.

rules

The rules parameter is an array of objects. Each object describes a separate rule for retrying commands.

Parameters this rule consists of:

ParameterTypeDefault valueDescription
conditionStringN/ACondition to retry: blank-screenshot or assert-view-failed. For more information, see below.
browsersString/RegExp/Array/.*/A list of browsers in which retries should run.
retryCountNumber2The number of retries.
retryIntervalNumber100Delay before each retry, in ms.
retryOnlyFirstBooleanfalseRetry only the first command in the test. This option is applied only at the assert-view-failed condition.

condition

The condition under which you need to retry. There are 2 values available:

  • blank-screenshot — retry the low-level screenshot command takeScreenshot if an empty screenshot is returned as a result of the command;
  • assert-view-failed — retry testplane's high-level command assertView to take a screenshot if it failed.

browsers

A list of browsers in which you need to apply low-level retries for commands. It can be set as a string (if it is one browser), a regular expression, or an array of strings/regular expressions. By default, the browsers parameter has the value /.*/, which all browsers fall under.

retryCount

The parameter determines how many times the command needs to be retried if the condition specified in the condition parameter is met.

retryInterval

The parameter specifies the time in milliseconds to wait before trying to repeat the command again.

warning

Be careful when setting a value for this parameter, as too large a value can dramatically reduce the speed of your tests.

retryOnlyFirst

Allows to retry only the first assertView command in the test if the value is set to true. This parameter is not used for other conditions.

Passing parameters via the CLI

All plugin parameters that can be defined in the config can also be passed as command-line options or through environment variables during the launch of Testplane. Use the prefix --retry-command- for command line options and testplane_retry_command_ for environment variables. For example:

npx testplane --retry-command-count 3
testplane_retry_command_count=3 npx testplane