# Environments: where your tests run

URL: https://testmode.ai/docs/environments/

> An environment is a named Base URL your Testmode tests run against. Add environments, mark production ones and set the default for runs and explorations.

An environment is a named copy of your site, such as Production, Staging or Preview, defined by its Base URL. You choose an environment each time you start a run, start an exploration or add a schedule, so the same test cases can check any copy of your app.

You manage environments for the current project under **Settings** > **Environments**. Every member can see the list. Viewers don't see **New Environment** or the edit and delete icons, and for them the star only shows which environment is the default.

## What an environment is

Each environment has three settings:

| Setting | What it does | Toolshop example |
| --- | --- | --- |
| **Name** | How the environment appears in the run and exploration dialogs. Names do not have to be unique. | `Staging (known bugs)` |
| **Base URL** | Where tests start. Must begin with `http://` or `https://`. | `https://with-bugs.practicesoftwaretesting.com` |
| **Production Environment** | Marks the environment as production (see below). | Off |

A test does not store an environment. When a test runs, Testmode opens the environment's Base URL plus the test case's Start Path. A test case with the Start Path `/contact`, run against Production at `https://practicesoftwaretesting.com`, starts at `https://practicesoftwaretesting.com/contact`. With no Start Path, the test starts at the Base URL.

[Screenshot: Environments settings listing Production with PROD and DEFAULT badges, Staging (known bugs) and Preview, with a Set as default tooltip on a star. Caption: Environments are the sites your tests run against; the star sets the default for runs and explorations.]

## Add an environment

**Before you start:** you need the Editor role or above, and a site that is reachable from the public internet, because tests run in a cloud browser.

1. Open **Settings** in the sidebar and click the **Environments** tab.

2. Click **New Environment** (or **Create Environment** if the project has none yet).

3. Enter a **Name**, for example `Staging (known bugs)`.

4. Enter the **Base URL**, for example `https://with-bugs.practicesoftwaretesting.com`.

5. Switch on **Production Environment** only if this is your live site.

6. Click **Save**.

Testmode shows "Environment created" and adds the environment to the list. Environments are listed oldest first.

You can also add a first environment while you [create a project](https://testmode.ai/docs/create-and-manage-projects/#add-an-environment-and-login-while-creating).

## Set a default environment

The default environment is the one Testmode picks for you when you start a run or an exploration.

**Before you start:** you need the Editor role or above.

1. Open **Settings** > **Environments**.

2. Click the star next to the environment you want. The tooltip reads "Set as default".

Testmode shows "Default environment set to" followed by the name. The star fills in and the environment gets a **DEFAULT** badge. A project has at most one default. To clear it, click the filled star again ("Remove as default"). Testmode then shows "Default environment cleared".

Where the default is used:

- **Run tests dialog and New exploration dialog:** the default environment is preselected. With no default, the oldest environment is preselected. You can always choose another one before you start.
- **New schedules:** a new schedule starts with the oldest environment selected, not the starred one. Check the **Environment** field when you add a schedule.

If you delete the default environment, the project simply has no default until you star another.

## Mark an environment as production

Switch on **Production Environment** when you add or edit an environment. The dialog then reminds you: "Be careful when running tests against production!"

What the production flag changes:

- A **PROD** badge appears next to the environment on the **Environments** tab, in the Run tests dialog, on the **Runs** page and run pages, on the **Overview** and on explorations.
- Explorations on a production environment always use **Observe** mode. **Interact** cannot be selected.

What it does not change:

- Test runs are not blocked, and Testmode does not ask for confirmation before running tests against production.

Your test cases decide what happens on the site. A test that places an order places a real order on any environment you run it against, production included. Run tests that create data, such as a Toolshop checkout, only against environments meant for testing.

## Edit or delete an environment

**Before you start:** you need the Editor role or above.

To edit, click the pencil on the environment's row, change the fields and click **Save**. Testmode shows "Environment updated".

A new Base URL takes effect for every test that has not started yet, including tests already queued in a run that is in progress.

To delete, click the trash icon on the row, then click **Delete** in the **Delete Environment?** dialog. Testmode shows "Deleted".

**Danger: Deleting an environment deletes more than the environment**

The confirmation dialog does not say so, but deleting an environment also permanently deletes:

- every run executed against it, with its test results
- the schedules that target it
- the explorations run on it
- credentials scoped to it (**Staging (known bugs) only**, for example), including their stored passwords

Test cases and project-wide credentials are kept.

## Good to know

- Variables are not filled in in a Base URL. Write the full address. Variables do work in a test case's Start Path; see [Variables](https://testmode.ai/docs/variables/).
- One environment covers one site. The agent may only navigate directly within the start host and its subdomains, so flows that move to another domain are not reliable.
- There is no per-test-case or per-plan environment. You choose the environment when you start the run or add the schedule.
- A site that is only reachable on `localhost`, on an intranet or through a VPN cannot be reached by the cloud browser. See [What Testmode can and cannot test](https://testmode.ai/docs/what-testmode-can-test/).

## Related

  - [Run tests](https://testmode.ai/docs/run-tests/): Pick an environment and start a run.
  - [Start an exploration](https://testmode.ai/docs/start-an-exploration/): Point the exploratory agent at an environment.
  - [Create and manage projects](https://testmode.ai/docs/create-and-manage-projects/): Create a project with its first environment.
