Get started

Command line

Introduction

CSTesting provides a command line interface for running tests, scaffolding a project, and running config-driven flows. Use the cstesting command (or the short alias cst). There are no optional flags (such as --headed or --grep); you control what runs by passing a file path, directory, or pattern.


Invocation

npx cstesting [command-or-pattern]
npx cst [command-or-pattern]

If you install CSTesting globally, you can run cstesting or cst without npx.


Essential commands

Run tests

Run test files. Discovered files must match one of: *.test.js, *.spec.js, *.test.ts, *.spec.ts. Tests run in headless mode by default (no visible browser). To see the browser, set headless: false in your test code or use a config file with headed=true.

Syntax

npx cstesting [pattern]
  • No argument — Uses default pattern **/*.test.js in the current directory (and subdirectories, excluding node_modules and dist).
  • Pattern — A file path, directory path, or glob. Only matching test files are run.

Examples

# Run all tests (default: **/*.test.js)
npx cstesting

# Run a single test file
npx cstesting tests/example.test.js
npx cstesting tests/landing-page.spec.ts

# Run all tests in a directory (and subdirectories)
npx cstesting tests/
npx cstesting tests/todo-page/
npx cstesting tests/landing-page/

# Run tests matching a glob
npx cstesting "**/*.test.js"
npx cstesting "**/login*.test.js"

# Run only tests that have a given tag (tag-based running)
npx cstesting --tag smoke
npx cstesting --tag smoke,regression tests/
npx cstesting -t login example/browser1.test.js

See Tags for how to tag tests and suites and use --tag / -t.

Test files are run one file after another (sequential). After the run, a summary is printed (Passed, Failed, Skipped, Total, duration) and the path to the HTML report is shown (e.g. report/report.html).

Discovered file types

ExtensionDiscovered
.test.jsYes
.spec.jsYes
.test.tsYes (requires ts-node in project)
.spec.tsYes (requires ts-node in project)

Scaffold (init)

Create the Page Object Model structure: pages/ and tests/ folders with sample HomePage.js and home.test.js. Does not overwrite existing files.

Syntax

npx cstesting init
npx cst init

Example

npx cstesting init

Output: lists created files and reminds you to run npx cstesting tests/.

Run config file

Run a config-driven flow from a .conf or .config file (no test code). See Config-driven tests.

Syntax

npx cstesting run <config-file>
npx cstesting <config-file>

Examples

# Using the run subcommand
npx cstesting run login.conf
npx cstesting run path/to/demo.config

# Or pass the config file directly (only for .conf / .config extension)
npx cstesting login.conf

The CLI looks for the file in the current directory (or the given path). After the run, the summary and report path are printed.

Output and report

  • Terminal — For each test file, the relative path is printed. Failed tests show suite name, test name, and error. At the end: Passed: X Failed: Y Skipped: Z Total: N (duration ms) and Report: <path>.
  • HTML report — Written to report/report.html (relative to current working directory). The report is not opened automatically. Open it manually (e.g. start report\report.html on Windows, open report/report.html on macOS).
  • Exit code — Process exits with code 1 if any test failed or if a config run had failures; otherwise 0.

There is no show-report command. Open the report file in your browser yourself.


What is not supported (current version)

The following CLI features from other tools are not implemented in CSTesting. Use the workarounds where applicable.

FeatureSupported?Workaround
Run tests (file, dir, pattern)Yes
init (scaffold)Yes
run config fileYes
--helpNoSee this doc or README.
--headedNoSet headless: false in code or use headed=true in a .conf file.
--grep / -g (filter by test title)NoFilter by file path or directory: run specific files or folders.
--workers / -j (parallel workers)NoTests run sequentially per file.
--debugNoUse Node/IDE debugger; run with headless: false to watch the browser.
--ui (interactive UI mode)NoNot available.
--project (browser/project)NoCSTesting uses a single browser (Chrome/Chromium).
--timeoutNoNo per-run or per-test timeout flag.
--max-failures / -xNoAll test files run; no "stop after N failures" option.
--last-failedNoRe-run failed tests manually by path if needed.
--list (list tests without running)NoNot available.
show-report (open HTML report)NoOpen report/report.html manually.
install (browsers)NoCSTesting uses system Chrome/Chromium; no browser install command.
codegen (record and generate tests)NoNot available.
show-trace / trace viewerNoNot available.
merge-reportsNoNot available.
clear-cacheNoNot available.
Config file (-c / --config)NoNo global config file; options are per call in code or in .conf for config-driven runs.
Run test at line (e.g. file.spec.ts:42)NoPass the whole file path only.
Test list file (--test-list)NoNot available.

Summary

CommandDescription
npx cstestingRun all tests (default pattern **/*.test.js).
npx cstesting <path>Run tests: path can be a file, directory, or glob (e.g. tests/, tests/a.test.js, **/*.test.js).
npx cstesting initScaffold pages/ and tests/ with sample POM files.
npx cstesting run <config>Run a config-driven flow (e.g. login.conf).
npx cstesting <file.conf>Same as run when the argument has extension .conf or .config.

Alias: npx cst is the same as npx cstesting.

No other subcommands or flags exist. For the latest behavior, run the CLI and refer to this document or the project README.