For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

SmartUI CLI Exec Command

SmartUI CLI exec command offers you various options to manage snapshot server and execute your visual testing scripts. This guide will walk you through the available commands and their usage.

Prerequisites​

  • Basic understanding of Command Line Interface
  • SmartUI CLI version 4.1.43 or higher installed for the start, stop and ping commands
  • A properly configured SmartUI CLI project

Available Commands​

SmartUI CLI offers the following exec commands:

  • npx smartui exec - Execute a command with SmartUI server running
  • npx smartui exec:start - Start the SmartUI snapshot server
  • npx smartui exec:stop - Stop the SmartUI snapshot server
  • npx smartui exec:ping - Check if the SmartUI server is running (uses custom HTTP client)
  • npx smartui exec:pingTest - Check if the SmartUI server is running (uses default HTTP client)

Using the Exec Command​

The npx smartui exec command allows you to run your tests with various configuration options. Here's the basic syntax:

Verified
npx smartui exec [options] -- <command>

Available Options​

OptionDescription
-P, --port <number>Specify a custom port number for the server (default: 49152)
--fetch-results [filename]Fetch test results and save to a JSON file (default: results.json)
--buildName <string>Specify a custom build name for the test run
--scheduled <string>Specify the schedule ID for scheduled test runs
--show-render-errorsShow render errors from SmartUI build
--userName <string>Override TestMu AI username (overrides environment variable)
--accessKey <string>Override TestMu AI access key (overrides environment variable)
--config <file>Specify a configuration file to use
-h, --helpDisplay help information

Examples​

  1. Running with a custom port:
Verified
npx smartui exec -P 5000 -- npm test
  1. Fetching results with custom filename:
Verified
npx smartui exec --fetch-results custom-results.json -- npm test
  1. Specifying a build name:
Verified
npx smartui exec --buildName "Release-1.0" -- npm test
  1. Using a configuration file:
Verified
npx smartui exec --config smartui-config.json -- npm test
  1. Combining multiple options:
Verified
npx smartui exec -P 5000 --buildName "Release-1.0" --config smartui-config.json --fetch-results -- npm test
  1. Running scheduled tests:
Verified
npx smartui exec --scheduled "schedule-123" -- npm test
  1. Showing render errors:
Verified
npx smartui exec --show-render-errors -- npm test
  1. Overriding credentials:
Verified
npx smartui exec --userName "user" --accessKey "key" -- npm test

Starting the Server​

To start the SmartUI snapshot server:

Verified
npx smartui exec:start

This will start a local server that handles snapshot requests. By default, the server runs on port 49152.

Stopping the Server​

To properly stop the SmartUI snapshot server:

Verified
npx smartui exec:stop

Important: It's recommended to use the exec:stop command rather than using Ctrl+C to terminate the server. Using Ctrl+C will cause the build to stop after 12 minutes of running.

Checking Server Status​

To verify if the SmartUI server is running, you can use either of these commands:

Using exec:ping (custom HTTP client):

Verified
npx smartui exec:ping

Using exec:pingTest (default HTTP client):

Verified
npx smartui exec:pingTest

Both commands check if the server is running at the address specified in SMARTUI_SERVER_ADDRESS environment variable (default: http://localhost:49152).

Running Tests with the Server​

Step 1: Configure Server Address​

For most test frameworks (except Selenium Java and JavaScript), you'll need to set the server address:

Verified
export SMARTUI_SERVER_ADDRESS='http://localhost:49152'

Step 2: Execute Your Tests​

You can run your tests using your preferred test runner:

Verified
# Using npm
npm test

# Using Maven
mvn test

# Using other test runners
your-test-command

IDE Configuration​

When running tests from IDEs like IntelliJ:

  1. Ensure the SMARTUI_SERVER_ADDRESS environment variable is set in your IDE's run configuration
  2. Configure the run configuration to use the appropriate test command

Best Practices​

Server Termination

Always use exec:stop to properly terminate the server.

Troubleshooting​

Server Status

Verify the server is running using exec:ping.

Getting Help​

If you encounter issues not covered here:

Additional Resources​

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles