There are various ways we can use parameters within to name a few we have -  Data-Driven Testing, Groups, Exports Parameters,  Configuration Files and Run Hooks and the Params file. Each override touches the test in different times, usually for different purposes. Let's review them.

The overriding Rules

Just like in most programming languages, where you define a variable, and override is later, the variable comprises the last value assigned to it. Similarly, you can override a value in Testim.

Before the test starts:

Note: All parameters sent to a test have Local level visibility (the entire test though is considered one big group).

During test run

The three visibility scopes are:

  • Local - variable lives in a group, and not accessible when group is completed
  • Test - variable lives in entirely/solely in the duration of the test
  • Test Suite - variable lives across multiple test executions (passed from test to test)

Overriding rules

the more specific the visibility is, the higher its importance.
I.e. If a variable is Local (most specific), it will always be used:
    exports.x = "local"
exportsTest.x = "test"
    exportsGlobal.x = "global"
    console.log(x); // prints "local"


Data driven:
Mostly used to create default set of values, which are will be overridden by the config file or the hooks.

Note: you can provide a set of parameters (array of objects) which then run the same test several times.

Params file:
Similar to Data driven, but are not for a specific test. Those will be passed to all tests. E.g. common credentials

Config files:
Used to dynamically load a suite of parameters. You can run custom JS code, which is executed in node.js, thus giving you the ability to load and run any NPM package. Common cases are loading from DBs or CSV files. You can find code examples here.

Note: beforeTest and beforeSuite does NOT support returning a set of parameters (an array). If you pass an array, it will be treated as an object (i.e. in this context, return ["x", "y" "z"] is ALMOST equivalent to return {1: "x", 2: "y",  3:"z"}).
In beforeSuite, please use the overrideTestData
beforeSuite() {    
  return {
       y: 5,
       overrideTestData: {
           "testname1": [{x: 6}, {x:7}] , // runs
testname1 twice
           "testname2": {y:7}          // y will be 5 because the overrideTestData object winds

Did this answer your question?