Testim Documentation

Welcome to the Testim documentation. You'll find comprehensive guides to help you get started quickly, example code snippets, and tips for being more productive. You will also find details about advanced features that allow you to customize Testim to fit your environment or special testing conditions. Don't worry, we'll support you if you get stuck. Let's jump right in!

Guides    Changelog

Advanced text validation

Use the power of regular expressions, JavaScript and parameters

Many time when you want to validate a text string, simple "exact match" is not enough. Here we'll show how to create advanced Text Validations, without the need of writing complete custom validations in JavaScript.

Using Regular Expression (Regex)

The Testim Editor supports Regex inside the Expected Value input. Let's cover the most common cases:

Starts with

Validates that the text starts with a certain word, allowing the rest of the text to be dynamic, and still pass the validation:
/^My text/

Ends with

Validates that the text ends with a certain word, allowing the rest of the text to be dynamic, and still pass the validation:
/my text$/

Contains

Validates that the text contains a certain word, allowing the rest of the text to be dynamic, and still pass the validation:
/my text/

Of course you can create and use any other valid Regex that you may need.

Tips

  • RegexOne is a great place to learn and practice regular expressions.
  • RegularExpressions 101 is a great tool for developing and testing a regular expression.

Using JavaScript expression

In other cases, you'd want to validate that a text equals the result of a JavaScript expression. For example, making sure that the the text holds the current date. In this case you can set the Expected Value to this simple expression: new Date().toDateString(), and The Testim Editor will compare the calculated string result of this expression. See a failed validation:

Using a parameter

Another advantage of the JavaScript expression, is that you can use a parameter created previously in a different step (more about exporting parameters).

For example I have exported from a prior step the user name to the parameter userName.
Now I want to validate that we greet the user accordingly - so we'll add a text validation on the greeting label:

And set it's value in the Properties panel to this JavaScript expression:
'Hello ' + userName + '!'

Advanced text validation


Use the power of regular expressions, JavaScript and parameters

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.