# Sandbox Testing

Sandbox Testing runs your application from the pull request branch in an Aikido-hosted sandbox and tests the changes. An agent plans extra tests for the pull request changes, covering what your CI doesn't. These tests only exist in the sandbox, to check the state of the deployment. Aikido Deploy doesn't add them to your repository as unit tests. This catches pull requests that pass CI but break when the application actually runs.

> **Note:** Sandbox Testing is part of Aikido Deploy. It does not need a staging environment, and it does not replace [smoke testing](https://help.aikido.dev/docs/docs-pt/aikido-deploy/smoke-testing.md), which runs against a live environment after a deployment.

## How it works

When a pull request gets your trigger label, Aikido Deploy:

1. Checks out the pull request branch in a sandbox.
2. Builds and starts the application, following your instructions.
3. Plans new tests that your CI doesn't cover, based on the pull request changes, then runs them in the sandbox.
4. Fixes failures it finds and pushes the fix to the pull request branch, then tests again.

Each retry sees the results of earlier attempts and reruns tests that failed to confirm the fix works.

Open the deployment in [Aikido Deploy](https://app.aikido.dev/deploy?regionRedirect=1) to follow the run. The Sandbox testing section shows the proposed tests and the agent activity for each one.

## Prerequisites

- Aikido Deploy is enabled for the repository. See [Aikido Deploy Overview](https://help.aikido.dev/docs/docs-pt/aikido-deploy/deploy-overview.md).
- You are an Aikido workspace admin.

## Enable Sandbox Testing

### Step 1: Open the repository settings

Go to **Deploy** in the Aikido app and open the repository.

### Step 2: Manage Sandbox Testing

In the **Sandbox Testing** section, click **Manage**.

### Step 3: Turn it on and add instructions

Turn on **Enabled**, then describe how to run the application locally in **Instructions**. Click **Save**.

The default instructions are `Look at README.md for instructions on running the app locally.` Replace them if your README doesn't cover how to run the application.

## Write good instructions

The instructions tell the sandbox how to start your application. Cover the things a new developer would need:

- How to install dependencies and start the application.
- Which services the application needs, such as a database, and how to start them.
- Any environment variables or setup commands the tests depend on.

Aikido checks new instructions before saving them. Instructions that try to change how Aikido Deploy behaves, reach other systems, or make unrelated changes are rejected. Describe how to run the application, nothing more.

## Limitations

- Sandbox Testing doesn't take screenshots or use a browser yet.
