V1 (latest)
Run tests locally
Run tests in any private environment, including local and CI machines.
This command requires an API key to authenticate against Momentic’s servers.
Overview
Run one or more Momentic tests using the current machine as the browser host. Any AI-enhanced steps are transmitted to Momentic’s servers for analysis. In this mode, your Momentic tests can access private environments, including sites only available on localhost
, deployed within a private VPC, or gated by VPNs.
Arguments
Argument | Description | Required |
---|---|---|
testFiles | One or more paths to files on disk. You may also pass a directory name, which will automatically include all test files under that directory. | Yes |
Options
Option | Description | Default |
---|---|---|
--shard-count <shardCount> . | Split the tests into separate shards for parallelizing when running with the --local flag. Each shard will run 1/shardCount of the total tests. | |
--shard-index <shardIndex> . | Which shard to run when using the --shard-count flag. | |
--pixel-ratio <pixelRatio> . | Momentic features that require calculating relative visual positions are affected by your monitor’s pixel density. If unsure, please visit this site to find your machine’s pixel ratio. | 2 when a MacOS Retina display is detected, otherwise 1 |
--input-csv <inputCsv> | Load test inputs from the specified file when running with the --local flag. | |
--no-report | Skip reporting test results to Momentic Cloud when running with the --local flag. | |
--start <start> | Arbitrary setup command that will run before Momentic steps begin. | |
--wait-on <waitOn> | URL to wait to become accessible before Momentic tests begin. | |
--wait-on-timeout <waitOnTimeout> | Max time in seconds to wait for the --wait-on URL to become accessible. | 60 |
--retries <retries> | Number of retries to attempt when running tests locally. Defaults to each test’s own retry configuration. | |
-p, --parallel <parallel> | When running with the --local flag, the number of tests to run in parallel. Defaults to 1. | 1 |
--env <env> | Name of the environment to use when running tests. | |
--url-override <urlOverride> | Fully qualified URL (e.g., https://www.google.com) to start all tests from. Overrides any default starting URL set from the test or environment. | |
--custom-headers HEADER-1=value HEADER-2=value | Add or override HTTP headers to be sent on every network request that occurs during the test. If this option is provided, you must use -- to separate the options from the test names provided (e.g. npx momentic@^1 run --custom-headers TEST=true -- my-test ). | |
--reporter <junit|allure> | Output standardized reports to disk based on the test results. Junit XMLs can be used with Junit visualizers while Allure JSON files can be bundled into static sites. | |
--reporterDir | Specify the folder to which standardized reports should be written. | reports |
--labels <labels...> | Only run tests that have at least one of the specified labels. Labels can be provided by using this flag multiple times, or as a list separated by spaces. |
Was this page helpful?