JavaScript testing frameworks

You can use the mabl-cli node package to run end-to-end tests locally in your preferred testing framework. The mabl-cli package exposes the MablTestRunner as an importable object that can be used to initialize and run mabl tests from within JavaScript testing frameworks such as Jest.

If this is your first time using the mabl CLI, please refer to the CLI overview documentation for additional information.

Early access program

This is an early access feature that is best evaluated together with the mabl Runner which is currently available to select customers under the mabl Early Access Program. Request access


Install the mabl-cli as another dev dependency in your project.

npm install @mabl/mabl-cli --save-dev

This install will use the same auth settings as the globally installed CLI tool. You’ll want to ensure your auth is active before running the tests. If not run mabl auth login.

Using inside a test

The createMablTestRunner function can be imported from the mabl-cli package and used to create a MablTestRunner. To run the test then call .run() on the MablTestRunner. Below is an example of a JavaScript test that will run a single test in headless mode and assert that there were no failures.

import {createMablTestRunner} from '@mablhq/mabl-cli';
describe('Run mabl tests locally', () => {
 it('Run single test', async () => {
   const mablTestRunner = await createMablTestRunner({
     testId: 'fb60BEqZa3kXZy1Gj0hAsA-j',
     branchName: 'master',
     headless: true,
   const result = await;

You may have to increase the default Jest timeout to accommodate the longer test runs. One way to do that is by specifying it globally: jest.setTimeout(30000);

createMablTestRunner([TestRunConfig]) <​Promise<MablTestRunner>>
An asynchronous function that creates a mablTestRunner with the specified test run config. One of the following options must be specified to run a test (testId | runId | labelsInclude), all others are optional.

  • TestRunConfig:
    Please see the following mabl help docs for info on obtaining needed test ids for the test run config or use the mabl-cli to query for them.
  • branchName <string>
    • The name of the mabl branch to run the test under
  • branchChangesOnly <boolean>
    • Only run tests that are on the specified mabl branch
  • credentialsId <string>
    • The credentials id to use in the test
  • environmentId <string>
    • The environment id to use in the test
  • fromPlanId <string>
    • the plan id to get a list of tests from. The environment id and the credentials id will be used as well unless supplied. Note: It is not a plan run and advanced plan configurations (e.g. stages, shared variables) will not be adhered to
  • headless <boolean>
    • Whether to run the test in headless mode or not
  • labelsExclude <Array<​string>>
    • An array of labels to exclude tests by when using labels to specify tests to run
  • labelsInclude <Array<​string>>
    • An array of labels query tests by and run sequentially
  • testId <string>
    • The test id to execute
  • runId <string>
    • The test run id to pull test info from for local run config. Will pull the environment, credentials, url, etc from that test run.
  • url <string>
    • The URL to run the test against
  • workspaceId <number>
    • The workspace Id to run the tests in, only needed when using labels as the primary config
      Returns a MablTestRunner. Call the run() function on to run the tests. <​Promise<TestResults>>
An asynchronous function that will run all the tests and return the test results.

All times are in milliseconds since the unix epoch.

  • Returns: TestResults
    • numFailedTests <number>
    • numPassedTests <number>
    • numSkippedTests <number>
    • numTotalTests <number>
    • testResults <Array<TestResult>>
      • status <string> (passed | failed | skipped)
      • errorMessage <string>
      • testName <string>
      • startTime <number>
      • endTime <number>
    • startTime <number>
    • endTime <number>
    • totalTimeSeconds <number>
      • Total test(s) time in seconds
    • success <boolean>

TypeScript support

The mabl-cli does include types for use in TypeScript. The types listed above should be available via import in TypeScript. See below for an example:

import {
} from '@mablhq/mabl-cli';
describe('mabl Execution Validation Tests', () => {
 it('Run single test', async () => {
   const testRunConfig: TestRunConfig = {
     testId: 'fb60BEqZa3kXZy1Gj0hAsA-j',
     branchName: 'master',
     headless: true,
   const mablTestRunner = await createMablTestRunner(testRunConfig);
   const result: TestResults = await;

Updated 3 months ago

Related resources

mabl CLI overview

JavaScript testing frameworks

Suggested Edits are limited on API Reference Pages

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