Prerequisites: These tests must exist locally as YAML files.

Run Momentic tests in the current project.

By default, tests will output results to a local directory. You can then upload results to Momentic Cloud using the momentic results upload command.

npx momentic run [options] [tests...]
  • [tests…]: The tests to run. If not specified, selects all tests in the current project. You can specify multiple tests separated by spaces, test paths, or folder paths. You can also pass substrings to match test names.

Options

-c, --config <config>

Path to the Momentic configuration file. If not specified, it defaults to momentic.config.yaml in the current directory.

npx momentic run --config path/to/momentic.config.yaml

-f, --filter <filter>

Only applicable when using Workspaces. Loads the project with the specified name.

npx momentic run --filter workspace-name

--custom-headers <customHeaders...>

Custom headers to include in the test run. You can specify multiple headers by separating them with spaces.

npx momentic run --custom-headers TEST=true OTHER_HEADER=true

--input-csv <inputCsv>

Path to a CSV file containing input data for the tests. Each row in the CSV file will be used as input for a separate test run.

npx momentic run --input-csv path/to/input.csv

--env <env>

The base URL set on the test will always take precedence over the environment. If you want to override the base URL set on the test, use the --url-override option.

The environment to run the test in. This will override any environment specified by the test.

npx momentic run --env env-name

--url-override <urlOverride>

The URL to override the base URL set on the test or the environment. This is useful if you want to run the test against a different URL than the one specified in the test or environment.

npx momentic run --url-override https://example.com

--start <start>

A command to run before starting the test. This can be used to start a local server or any other command that needs to be run before the test starts.

npx momentic run --start "npm run start"

--wait-on <waitOn>

The resource to wait for before starting the test. This can be a URL, a file, or any other resource that can be waited on. This is useful for ensuring that the resource is available before starting the test.

npx momentic run --wait-on http://localhost:3000

--wait-on-timeout <waitOnTimeout>

The timeout for the --wait-on option. If the resource is not available within this time, the test will fail.

npx momentic run --wait-on http://localhost:3000 --wait-on-timeout 30000

--retries <retries>

The number of times to retry a test if it fails.

npx momentic run --retries 3

-p, --parallel <parallel>

The number of tests to run in parallel. This can be useful for speeding up test execution, especially for large test suites. Each test will start its own browser instance.

npx momentic run --parallel 5

--labels <labels...>

Run tests with the specified labels. This allows you to filter tests based on assigned labels.

npx momentic run --labels smoke regression

--update-golden-files

Update the golden files for Visual diff.

npx momentic run --update-golden-files

--reporter <reporter>

Specify the reporter to use for the output. Momentic supports the following reporters: junit, allure-json, and playwright-json.

npx momentic run --reporter junit

--reporter-dir <reporterDir>

Specify the directory where the reporter output will be saved. If not specified, it defaults to ./reports.

npx momentic run --reporter junit --reporter-dir ./reports

--output-dir <outputDir>

Directory to store run artifacts such as screenshots, results, and logs. This directory will be cleared at the start of execution.

npx momentic run --output-dir ./output

--shard-index <shardIndex>

The index of the shard to run. This is used in conjunction with --shard-count to determine which tests to run in this shard. This is useful for running tests in parallel across multiple machines or processes. The index starts at 1.

npx momentic run --shard-index 1 --shard-count 3

--shard-count <shardCount>

The total number of shards to run. This is used in conjunction with --shard-index to determine which tests to run in this shard. For example, if you have 3 shards and you set --shard-index to 1, only the tests that belong to the first shard will be executed.

npx momentic run --shard-index 1 --shard-count 3

--include <includePatterns...>

Only include tests that match the provided regex patterns. Multiple patterns can be provided. The patterns will be matched against the test file paths and the pattern only needs to match a part of the path for the test to be included.

npx momentic run --include "billing*"

--exclude <excludePatterns...>

The opposite of --include: a test that matches any of the provided regex patterns will be excluded from running.

npx momentic run --exclude "billing*"