# Testing your code

The **Test runner** lets you fire a sample request at your integration without setting up a real external service — so you can confirm your code behaves before going live.

## Running a test

1. In the editor toolbar, click **Test**.
2. Choose the HTTP **method** — `GET`, `POST`, `PUT`, or `DELETE` (defaults to `POST`).
3. Enter request **headers** as JSON, e.g.:

   ```json
   { "Content-Type": "application/json" }
   ```
4. Enter the request **body** as JSON — paste a realistic payload from the service you're integrating:

   ```json
   { "event": "payment.succeeded", "amount": 49.0, "customer": "Jane Doe" }
   ```
5. Click **Run Test**.

Studio runs your current code against this request and reports the result.

## Valid JSON required

The headers and body fields must contain valid JSON. If they don't, Studio shows **"Invalid JSON format"** and won't run the test until you fix it. Empty fields are treated as `{}`.

## Reading the result

After a test run, check [Request history](/introduction/justpush-studio/testing-and-monitoring/request-history.md) to inspect the full outcome — the parsed request, your **console output**, and the result of the run — exactly as you would for a real webhook.

## Tips

* **Use real payloads.** Copy an actual example from your provider's docs or a captured request so your test matches production.
* **Test the edge cases.** Try payloads with missing fields, unexpected event types, and empty bodies to make sure your code fails gracefully (see the guard examples in [Examples](/introduction/justpush-studio/writing-code/examples.md)).
* **Save first.** The test runs your current editor code; save it as a revision once it works.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.justpush.io/introduction/justpush-studio/testing-and-monitoring/testing-your-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
