Creating API tests

How to create API tests in mabl

This guide outlines how to set up a base API URL in your mabl workspace and create a new API test.

📘

Enterprise feature

API testing is available to trial users and customers on enterprise subscription plans.

Configuring your environment

If the API URL has already been added to your mabl workspace, skip ahead to the section on creating a new API test. If not, you'll need to add a base URL for an API to an application in your mabl workspace:

  1. Navigate to Configuration > Applications.
  2. Click on the URL for a specific app/env. An edit modal will appear.
  3. Click Add URL.
  4. Choose API for the type and enter the base URL.

👍

Omit the trailing slash

When you add a base API URL to an application/environment, leave out the trailing slash at the end of the URL. (For example, write https://example.com, NOT https://example.com/.)

Omitting the slash allows for more readable requests when working in the API test editor: {{@api.url}}/users instead of {{@api.url}}users.

24862486

Adding an API URL to a mabl application/environment

  1. Click Save to confirm your changes. This update will create a variable called api.url for that specific application/environment.

After adding a base API URL, you can create your first API test in mabl from scratch or import an existing Postman Collection.

Creating a new API test

Follow these steps to create a new API test:

  1. Click on the New test button in the left-hand navigation.
  2. Choose API test as the test type. A form to create a new API test will appear.
12611261

Creating a new API test

At a minimum, you must define the test name and the API under test.

A full list of configurations that can be applied to an API test follows:

The basics

  • Test name: we recommend establishing a naming convention for tests with other members of your workspace so that you can easily locate tests and understand what they do.
  • Test description: descriptions give more context or explanation for a test.
  • Test labels: Useful for sorting and triggering ad hoc runs from the mabl CLI.

Add to plan

You may choose to add the test to an existing plan, create a new plan, or not add the test to a plan at all:

  • Existing plan: Choose the plan from the dropdown. The test will use the application environment(s) that are configured for the existing plan.
  • New plan: Enter the plan name and select the application and environment that the plan should run in.
  • No plan: Select the application and environment for the test.

📘

API URL required

It is not possible to add an API test to a plan or application that lacks a base API URL. To add an API URL to an application, see Configuring your environment.

Show advanced options

You can associate the API test with a DataTable. If you want to train an API test with a DataTable, follow the instructions outlined here.

🚧

Test size limits

Please note that API tests cannot exceed 1MB in size. We recommend using caution with large JavaScript scripts.

After filling out the browser test creation form, click on Create test to open the API Test Editor and add steps!

Learn more


Related resources