The configuration file is a common JS containing all the required parameters to run your test suite and (optional) run hooks which can be used to set up the application backend before/after a single test or all tests.

The configuration file needs to export all properties in a JSON named config.

Here is an example of a configuration file:

JavaScript

exports.config = {

    project: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   
    // Specify which label you would like to run. All tests with the
    // specified label will be executed
    label: "sanity",
   
    // Your Selenium grid
    grid: "<Your grid name>",
   
    // Override the base URL defined in the test in order to run it again a     // different envinronment
    baseUrl: 'http://staging.example.com',

    // =====
    // Hooks
    // =====
    // Testim provides several hooks you can use to interfere the test
    // process in order to enhance it and build services around it.
   
    // Hook that gets executed before the suite starts
    beforeSuite: function (suite) {
        console.log("beforeSuite", suite);
    },
   
    // Function to be executed before a test starts.
    beforeTest: function (test) {
        console.log("beforeTest", test);
    },
   
    // Function to be executed after a test starts.
    afterTest: function (test) {
        console.log("afterTest", test);
    },
   
    // Hook that gets executed after the suite has ended
    afterSuite: function (suite) {
        console.log("afterSuite", suite);
    }
};

Note:  For the grid name, read here how to set up your grid.

The configuration file supports all the properties described in the CLI document.
The name structure of the property is slightly different, replace the hyphen(-) with a capital letter. For example: base-url => baseUrl.

When you need to send more than one value to a parameter, use an array.
For example: label: ["a" , "b"]

Global exports parameters

In "afterSuite" function you can use exports global parameters exported at your run.
Syntax: suite.exportsGlobal.<param_name>
Read more about exports global parameters here.

How to use it

  1. Create your configuration file (e.g. testimConfig.js)
  2. Pass it to the Command Line (CLI) runner as a parameter:
  3. Make sure to indicate the path to the file if needed.

Shell

testim -c "testimConfig.js"
  1. If you want to override one of the values in the configuration file, simply pass it explicitly to the CLI, like this:

Shell

testim -c "testimConfig.js" --label "nightly"
Did this answer your question?