Evaluating as a JS-expression

Include calculations and JS-features in your scenarios 🧠

There is an opportunity to turn on evaluating your expression as a JavaScript code (ECMAScript 5.1):

Turning ON/OFF the option in a filter

Remember, that if you turn on this option and make a mistake in the syntax, the scenario will stall with an exception message.

Checking the expression

You can check the result of evaluating you expression by clicking Check the expression link. Here you have to provide an ID of the object:

Checking the expression providing an object with ID=1

Don't mix "Check the expression" feature with step testing.

Examples of evaluating as a JS expression

Expression

🅾️ JS-interpreter is off

✅ JS-interpreter is on

{{a}} +1

// {{a}} = 3

3 + 1

4

Math.random()

Math.random()

0.4353

// some random value 0.0–1.0

Today +1 day

and similar expressions

Today +1 day

2020-05-04T00:00:00.000Z

// today at 00:00

'{{a}}'.length

// {{a}} == hello world

'hello world'.length

12

'{{a}}'.length

// {{a}} == 1,-12,hello (array type)

'1,12,hello'.length

11

// Note! It evaluates as a string.

Learn how to deal with arrays

Don't forget to quote the '{{fields}}' if you want them to be processed as string.