A Script assertion allows to write a JavaScript test script. The script itself is a function named test, that takes an assertion object and an object with variables (a key/value pair). If the function returns true the test is successful. If it returns false or raises an exception, then the Script assertion failed.

Deprecated syntax:

We strongly recommend you use a new way of creating test scripts instead of the test function. You’ll get an opportunity to use an API to access any entity in your project, use build-in helper libraries (such as lodash and chai), and define a detailed description for every test assertion, that will be displayed in the console and errors list.

Your tests created via the test function will be working properly but this syntax won’t be supported in further major releases.


Script assertions support the same API as Script nodes

A script assertion test is considered to be failed if you get any kind of exception while running the script; otherwise, the test is passed.

User Interface

The Assertion has the interface of a Script node:

The Name field contains a short description of the test.

Error Fixing

This assertion doesn't have any error fixing algorithm.

File Representation

The assertion has the script type in the file. The type description can be found in Assertion file representation Assertion file representation documentation in the #/definitions/ScriptAssertion definition.