> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getnexor.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Test a Scheduled Function

> Run the draft of a Scheduled Function, or its published code, without real effects: reads are sent, writes are recorded as would-send with a synthetic answer, and lead changes are only previewed.

Run the draft of a Scheduled Function on a test copy that cannot change anything. Without a draft, the test runs the published code.

## What happens during a test

| Your code does | During a test |
| - | - |
| A `GET`, `HEAD`, or `OPTIONS` request | Sent for real, with your headers and environment variables. |
| Any other request (`POST`, `PUT`, `PATCH`, `DELETE`) | Not sent. Your code receives a `200` response with the body `{}`. The request is recorded in `run.requests` with `blocked: true` and its body, so you can review what would have been sent. |
| Lead changes and other effects | Returned as a preview and never applied. This includes `updateEnvironmentVariable`. |
| `WebSocket` or `EventSource` | Throws an error. |

Without `ctx`, the test loads the leads, agents, and hosts that the saved lookup scope matches now. Loading them only reads data.

A test has the same time and request limits as a real execution. It appears in run history with `trigger_source` `test`, but it does not change `run_count`, `last_run_at`, or `last_run_status`.

<Warning>
  **Accepted risks of a test**

  * A `GET` that changes something in the other system, such as an unsubscribe link or a webhook triggered by a `GET`, runs for real.
  * Writes get a synthetic `{}` answer. Code that reads fields from that answer, such as an ID it expects back, can take a different branch than in production.
  * A write sent through `globalThis.fetch` instead of the provided `fetch` or `axios` is also held back, but it is not listed in `run.requests`.
  * A raw TCP connection opened with a socket API is not held back.
</Warning>

## Read the result

* `run.status` is `success`, `error`, or `timeout`. An error in your code is a successful call with `run.status` `error`.
* `run.effects` lists the previewed lead changes.
* `run.requests` lists every request made through `fetch` or `axios`. The ones with `blocked: true` were not sent.
* `run.mode` is `test`.

A 503 `DEPLOYMENT_NOT_CURRENT` means the test copy could not be prepared. Nothing ran and nothing was recorded. Retry in a moment.

To verify a real write, publish the code while the function is paused, then use [Run now](/docs/en/api/scheduled-functions/run-scheduled-function) after the operator confirms.


## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.getnexor.ai/llms.txt).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.