# 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="script" %}
[script](https://docs.testmace.com/node-types/assertion-node/script)
{% 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.
