Testim Documentation

Welcome to the Testim documentation. You'll find comprehensive guides to help you get started quickly, example code snippets, and tips for being more productive. You will also find details about advanced features that allow you to customize Testim to fit your environment or special testing conditions. Don't worry, we'll support you if you get stuck. Let's jump right in!

Guides    Changelog

Getting started with Root Cause Cloud

To get started with Root Cause Clous you must first signup. If you want to use Root Cause Cloud in standalone mode (i.e. without a test runner), follow the instructions in the Standalone Mode Setup section. Or, if you are using a test runner (Jest/Mocha), follow the instructions in the Test Runner Mode Setup section. After running your tests, you will be able to access the results through Root Cause web-based system, see Cloud tests results.

Sign up to Root Cause Cloud

In order to use Root Cause cloud, you must first signup. Root Cause Cloud offers a substantial free usage tier. See pricing for more information.

Standalone Mode Setup

Root Cause in standalone mode offers the same functionality, but without using a Test Runner.
To setup Root Cause in standalone mode:

  1. Use the following command to install the Root Cause Node.js package (you may also use the yarn equivalent command):
npm install @testim/root-cause
  1. Add the following lines to your test:
const rootcause = require('@testim/root-cause');
 
rootcause.launch({ testName: "My Root Cause test" }, async page => {
    // use the page object normally like you regularly would
 
    await page.goto('https://example.com');
    await page.click('a');
});
import playwright from 'playwright';
    import * as rootcause from '@testim/root-cause';
    

    rootcause.launch({ testName: __filename, automationLibrary: 'playwright' }, async (page) => {
        await page.setViewportSize({
            width: 1400,
            height: 800,
        });
  1. Connect your environment to the Root Cause cloud service by copying the following code and adding it as an environment variable:
  • For Windows:
set TESTIM_PROJECT_ID=loJlaFSo1tmNzreV9DJQ
set TESTIM_PROJECT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
set TESTIM_PERSIST_RESULTS_TO_CLOUD=true
  • For MacOS:
export TESTIM_PROJECT_ID=loJlaFSo1tmNzreV9DJQ
export TESTIM_PROJECT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export TESTIM_PERSIST_RESULTS_TO_CLOUD=true
  • For Linux:
export TESTIM_PROJECT_ID=loJlaFSo1tmNzreV9DJQ
export TESTIM_PROJECT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export TESTIM_PERSIST_RESULTS_TO_CLOUD=true
  1. Run whatever test command you usually run.
npm test

Test Runner Mode

If you are using test runner, such as JEST or Mocha, you will need to follow the steps below.
To setup Root Cause in Test Runner mode:

  1. Use the following command to install the Root Cause Node.js package (you may also use the yarn equivalent command):
  • For Jest:
npm install @testim/root-cause-jest
  • For Mocha:
npm install @testim/root-cause-mocha
  1. Copy the following code and add it to the to your test runner configuration:
  • For Jest-puppeteer:
// inside your jest.config.js
const runId = Date.now().toString(); // name the suite run somehow
module.exports = {
    // add the Root Cause Reporter
    reporters: [['@testim/root-cause-jest/lib/reporter/default', { runId }],
    // and tell Testim Root Cause to instrument
    // Note we expect a global 'page' object, for example like in jest-puppeteer
  • For Jest-Playwright:
const playwrightPreset = require("jest-playwright-preset/jest-preset.json");

const runId = Date.now().toString();

module.exports = {
    ...playwrightPreset,
    testRunner: 'jasmine2',
    reporters: [
        ['@testim/root-cause-jest/lib/reporter/default', { runId }],
    ],
    setupFilesAfterEnv: [
        ...playwrightPreset.setupFilesAfterEnv, '@testim/root-cause-jest/lib/forSetupFilesAfterEnv'
    ],
    globals: {
        runId,
    },
};

📘

Note

Note – for additional integration options see Root Cause Jest integration

  • For Mocha - Puppeteer/Playwright:
//inside your mocharc
        module.exports = {
            "require": ["@testim/root-cause-mocha/rootHooks"],
            "reporter": "@testim/root-cause-mocha/reporter"
        }

📘

Note

For additional integration options see Root Cause Mocha integration

  1. Connect your environment to the Root Cause cloud service by copying the following code and adding it as an environment variable:
  • For Windows:
set TESTIM_PROJECT_ID=loJlaFSo1tmNzreV9DJQ
set TESTIM_PROJECT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
set TESTIM_PERSIST_RESULTS_TO_CLOUD=true
  • For MacOS:
export TESTIM_PROJECT_ID=loJlaFSo1tmNzreV9DJQ
export TESTIM_PROJECT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export TESTIM_PERSIST_RESULTS_TO_CLOUD=true
  • For Linux:
export TESTIM_PROJECT_ID=loJlaFSo1tmNzreV9DJQ
export TESTIM_PROJECT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export TESTIM_PERSIST_RESULTS_TO_CLOUD=true
  1. Run whatever test command you usually run:
npm test

Updated 6 months ago


What's Next

After running tests, check out the results.

Suite runs view
Test runs view

Getting started with Root Cause Cloud


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.