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

Running code in Node.js

Execute Node.js scripts from within your tests

In addition to writing Custom validations and actions scripts (which execute in the browser run-time environment), you can also create custom Node.js scripts that will be executed in your CLI environment.
These scripts will be executed from inside a test with context just like a standard custom action. It opens the gateway for some very advanced actions such as database validation and manipulation, image and PDF validations, and many more (see usage examples below).

Creating a CLI action

You can create a CLI action step just like you would create a normal custom action and validation.

Running CLI action steps locally

When running locally (as opposed to running from the CLI) we need to provide the CLI action steps a Node.js environment in which to execute the code in.;
When you try to locally run a test which contains a CLI action step, you will be asked to provide this runtime environment. To do this, simple execute the following command from your shell:
npm i -g @testim/testim-cli && testim --agent

Adding node packages

Executing Node.js scripts from inside the context of a test is great, but the real power of CLI actions comes from the ability to add any node package directly from npm (or any other source) and have those packages scoped to the CLI action step during test execution.

We support all the standard methods for defining packages dependencies. Visit this page for more information about the various options and syntax.

Async code

To run async code in the CLI action you have to return the promise you wish to resolve.
Without returning it, the step will run synchronously and will resolve when the last line of code is executed, regardless of the expected results.

Note:
This is an advanced feature, to enable it please reach out via our chat or contact your CSM.

CLI action examples:

Updated 17 days ago

Running code in Node.js


Execute Node.js scripts from within your tests

Suggested Edits are limited on API Reference Pages

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