> For the complete documentation index, see [llms.txt](https://docs.testmace.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testmace.com/node-types/assertion-node/script.md).

# Script

A **Script assertion** allows to write a JavaScript script to check an assertion. The script itself is a function named `test` which takes an assertion object and an object with variables (in a key-value format) as arguments. If the function returns `true`, the assertion was successful. If it returns `false` or raises an exception, the **Script assertion** failed.

{% hint style="warning" %}
**Deprecated syntax:**

We strongly recommend you use a new way of writing test scripts instead of defining the `test` function. You'll have an opportunity to apply the API to all entities in your project, use built-in helper libraries (e.g. `lodash` and `chai`), and define a detailed description for every test script, which will be shown in the error list and in the console.

Your tests written via the `test` function will still be working, but in future major releases this syntax won't be supported.
{% endhint %}

### New API

**Script assertions** support the same API as **Script** nodes do.

{% content-ref url="/pages/-LgrLaD6CE1ahNm\_mV9h" %}
[Script](/node-types/assertion-node/script.md)
{% endcontent-ref %}

If while running a script an exception of any kind was raised, this **Script assertion** run is considered to be unsuccessful and successful otherwise.

### User Interface

This **Assertion** interface is similar to the one of a **Script** node:

![](https://gblobscdn.gitbook.com/assets%2F-Lh_FaVh9XfQJ0p1KqZ1%2F-M2Th-pSAXk8IEvHySm4%2F-M2ThBMbiJ2D7aKV15Di%2FTestMace%202020-03-15%2018.58.58.png?alt=media\&token=a133ee76-b15e-4e6a-a6bd-38b454c17fbd)

The **Name** field allows to set a description for test of this kind.

### Error Fixing

This **Assertion** doesn't have any error fixing algorithm.

### File Representation

The **assertion** is of the `script` type in the file. The type description can be found in the [Assertion file representation](https://docs.testmace.com/node-types/assertion-node#file-representation) documentation in the `#/definitions/CompareAssertion` definition.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.testmace.com/node-types/assertion-node/script.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
