Skip to main content

system

Overview​

The system section in Testplane settings is not mandatory.

Use it to:

  • enable debug mode for WebDriver;
  • change mocha timeouts for tests;
  • add some data to the global context that all tests will see;
  • specify error types that should close the current browser session permanently instead of trying to reuse it;
  • stop the entire run when a configured failure limit is reached;
  • set the number of subprocesses in which tests will run to speed up their execution;
  • define the maximum number of browsers available at one time (this can be relevant if you get browsers from a cloud service with such limitations);
  • set file extensions among which Testplane will search for tests;
  • etc.

Example configuration of the system section:

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
debug: false,
mochaOpts: {
timeout: 60000,
},
expectOpts: {
wait: 3000,
interval: 100,
},
ctx: {
/* ... */
},
patternsOnReject: [/timeout/i, /timedout/i, /timed out/i],
maxFailures: Infinity,
workers: 1,
testsPerWorker: Infinity,
parallelLimit: 15,
fileExtensions: [".js", ".ts"],
},
} satisfies ConfigInput;

System Section Reference​

ParameterTypeDefaultDescription
debugbooleanfalseEnable/disable debug mode for WebDriver.
expectOptsExpectOptssee belowexpect-webdriverio options.
mochaOptsMochaOptssee belowAdditional options for mocha.
ctxRecord<string, any>{ }Context that will be available in all tests via the testplane.ctx method.
patternsOnRejectRegExp[][ ]List of error patterns. The session will be closed if a test fails with an error matching one of the specified patterns. A new session will then be created to avoid infrastructure issues.
maxFailuresnumber | { limit: number; patterns: (string | RegExp)[] }InfinityMaximum number of failed attempts before cancelling the entire run; optionally counts only errors matching specified patterns.
workersnumber1Number of subprocesses that will be launched to run tests.
testsPerWorkernumberInfinityMaximum number of tests that will be run in one subprocess before the subprocess is restarted.
diffColorstring"#ff00ff"Color to display the diff in screenshots.
parallelLimitnumberInfinityMaximum number of browsers that can be launched simultaneously.
fileExtensionsstring[][".js", ".mjs", ".ts", ".mts", ".jsx", ".tsx"]File extensions in which Testplane will search for tests to run.
testRunEnvnodejs or browser or ArraynodejsAbility to specify in which environment the tests should be run.

debug​

Enables debug mode for WebDriver if set to true. In this mode, detailed information about each command sent to the browser will be output to the console.

Default: false.

expectOpts​

Options for expect-webdriverio. Allows changing the timeout and interval between attempts to find an element.

Default:

const defaultExpectOpts = {
wait: 3000,
interval: 100,
};

mochaOpts​

Additional options for mocha, which are passed to mocha.setup. See the list of available options in the Mocha documentation. Default: { timeout: 60000 }.

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
mochaOpts: {
timeout: 60000,
},
},
} satisfies ConfigInput;

ctx​

Context that will be available in all tests via the testplane.ctx method. Intended for sharing some data between all tests without resorting to using global variables.

Example usage:

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
ctx: {
services: ["video", "images"],
},
},
} satisfies ConfigInput;
it("awesome test", function () {
console.log(testplane.ctx); // { services: ['video', 'images'] }
});
tip
Use testplane.ctx in tests instead of global variables.

patternsOnReject​

The session will be closed if a test fails with an error matching one of the specified patterns in patternsOnReject. A new session will then be created to avoid infrastructure issues.

Example:

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
patternsOnReject: [/timeout/i, /timedout/i, /timed out/i],
},
} satisfies ConfigInput;

maxFailures​

Available from testplane v9.5.0

Sets a failure limit for the entire test run. Once the limit is reached, Testplane emits a critical error, cancels the remaining tests, and exits the CLI with a non-zero code.

Default: Infinity (no limit). The limit must be a positive integer or Infinity; 0 is not allowed.

There are two configuration forms:

  • A number counts all failed test attempts.
  • An object { limit, patterns } counts only attempts whose error message matches at least one pattern. Both fields are required. Patterns can be strings or regular expressions; strings are interpreted as regular expression sources. An empty patterns array matches nothing.

For example, start cancelling the run after three errors containing Service unavailable, ignoring case:

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
maxFailures: {
limit: 3,
patterns: [/Service unavailable/i],
},
},
} satisfies ConfigInput;

The first two matching failures do not trigger cancellation. Errors that do not match the pattern do not increase this counter.

To count all errors, use a numeric limit:

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
maxFailures: 20,
},
} satisfies ConfigInput;

The counter is shared across all tests, browsers, and patterns within a run. Each failed attempt counts once, even if several patterns match. Failed attempts followed by test retries also count; a later successful retry does not reset the counter. Internal WebDriver HTTP retries are not counted separately: Testplane counts the failed test attempt when it receives the resulting error.

Cancellation starts at the configured limit, but already started attempts and session requests may still finish. Cancelled tests can also appear as failures in the report. The limit therefore does not guarantee exactly that many failed tests in the final report or HTTP requests to the grid.

workers​

Testplane runs all tests in subprocesses to reduce CPU usage for the main process and avoid memory limitations for Node.js. This option sets the number of subprocesses that will be launched to run tests. Default: 1.

testsPerWorker​

Maximum number of tests that will be run in one subprocess before the subprocess is restarted. Default: Infinity.

diffColor​

Color for displaying the diff in visual checks using the browser.assertView command.

Default: "#ff00ff".

parallelLimit​

By default, Testplane launches all browsers simultaneously. Sometimes (e.g., when using cloud services like SauceLabs) you may need to limit the number of browsers that can be launched simultaneously. This option sets that limit. Default: Infinity.

fileExtensions​

File extensions in which Testplane will search the file system for tests to run. Default: [".js", ".mjs", ".ts", ".mts", ".jsx", ".tsx"].

testRunEnv​

Allows specifying the environment in which tests should be run. The following environments are available:

  • nodejs — Testplane will run tests in Node.
  • browser — Testplane will run tests in the browser.

When using the browser value, you can specify additional options:

  • viteConfig — custom Vite config. You can specify a string — path to the configuration file, an object — UserConfig or a function — with the type (env: ConfigEnv) => UserConfig | Promise<UserConfig>.

Usage examples:

testplane.config.ts
import type { ConfigInput } from "testplane";

export default {
// ...
system: {
testRunEnv: ['browser', { viteConfig: './vite.config.ts' }]
},
}