Scripts within tests and stubs

You can use scripts in Test Integrations and APIs that include the Test Integrations and APIs legacy scripting language, ECMAScript (such as JavaScript), Chai, or any third-party scripting language that you install.

You can use scripts in many test actions, such as Assert, Decision, and Function actions, and in the Assert using Function actions in the message editor. The scripts in these actions return a value or perform an action (for example, a database update).

When you use scripts in certain test actions, for example the Function action, the value received from the response is stored in a tag. When you use scripts that check for a Boolean value (true or false) in responses in other test actions, the script validates the test response for a successful test run.

The custom functions that you add to an Test Integrations and APIs project are available while you use scripts.
Notes:
  • When you use a scripting language other than Test Integrations and APIs legacy scripts, the functions and data types of the scripting language are also available.
  • When you use a scripting language that is not provided by Test Integrations and APIs, the built-in functions and project custom functions are not available.
  • Starting from Test Integrations and APIs 9.2.1, when you use the ECMAScript 5 language, the syntax is checked, and the invalid code is highlighted.
  • Starting from Test Integrations and APIs 10.1.1, you can use Chai, which is the default scripting option in the Assert, Decision, and Function test actions in Test Integrations and APIs.
Test Integrations and APIs provides many opportunities for dynamic user interaction that include the following actions:
  • Function actions. See Function.
  • Guard conditions in a message-based stub. See The Input tab.
  • Message cases in Message Switch actions. See Message cases.
  • Expressions for Assert, Decision, or Iterate While actions. See Flow actions.

You can right-click within the editor, and then select Test to see the output of the filter expressions by using the values of any included tags.

Test option

You can also click Test from the editor window, specify temporary values for any tags, and run the test to see the output.

Test button

Test button output