Command Line
TSTyche ships with the tstyche
command and a set of useful options.
Usage
When called without arguments, the tstyche
command runs all test files matched by the testFileMatch
patterns. To select particular files, pass one or more arguments:
# Run all tests
tstyche
# Only run the test files with matching path
tstyche ./path/to/first.test.ts
Only the files matched by the testFileMatch
patterns can be selected. The search strings are matched with the portion of the path relative to the current directory. The matching is case insensitive.
If glob patterns (opens in a new tab) are supported in your shell, you can use them as well.
Options
Options passed through the command line override the ones from the configuration file.
An option does not take a value, if its type is not specified. Otherwise, the parsing logic of the option value depends on its type:
- boolean is interpreted as
true
, if the value is omitted or set totrue
; or asfalse
, if set tofalse
, - string is simply a string,
- list can hold one or several values separated by commas:
--target 4.9
or--target 4.9,current
.
Relative paths are resolved relative to the current directory.
Use the --showConfig
command line option to inspect the resolved configuration.
--config
- Type: string
The path to a TSTyche configuration file.
tstyche --config ./config/tstyche.json
--failFast
- Type: boolean
Stop running tests after the first failure.
--help
Print the list of command line options with brief descriptions and exit.
--install
Install specified versions of the typescript
package and exit.
--install
must be used together with the target
configuration option or the --target
command line option. The versions specified via the --target
command line option are added, if it is provided; otherwise the versions listed in the target
array in the configuration file are added.
# Install TypeScript 4.9.5
tstyche --install --target 4.9
# Install the specified versions of TypeScript
tstyche --install --target 4.7,latest
--listFiles
Print the list of the selected test files and exit.
--only
- Type: string
Only run tests with matching name. The given string is matched against the name of every test()
or describe()
entry. The matching is case insensitive.
--only
does not override the .skip
run mode flag. If both --only
and --skip
filters select a test, it gets skipped.
tstyche --only external
--prune
Remove all installed versions the typescript
package and exit.
--plugins
- Type: list of strings
The list of plugins to use.
The following can be specified:
- name of a package:
"tstyche-plugin"
, - or a path:
"./custom-plugin.js"
.
tstyche --plugins tstyche-plugin,./custom-plugin.js
To learn more, see the Plugins page.
--reporters
- Type: list of strings
The list of reporters to use.
The following can be specified:
- built-in reporter:
"list"
or"summary"
, - name of the package:
"tstyche-reporter"
, - or a path:
"./custom-reporter.js"
.
tstyche --reporters list,tstyche-reporter,./custom-reporter.js
To learn more, see the Reporters page.
--showConfig
Print the resolved configuration and exit.
--skip
- Type: string
Skip tests with matching name. The given string is matched against the name of every test()
or describe()
entry. The matching is case insensitive.
--skip
overrides the .only
run mode flag. If both --skip
and --only
filters select a test, it gets skipped.
tstyche --skip internal
--target
- Type: list of strings
The list of TypeScript versions to be tested on.
The following can be specified:
current
is the version of TypeScript currently installed in the project,- minor releases, like
5.2
or4.9
, resolves to the latest version in the serries (for example,4.9
resolves to version 4.9.5), - patch releases, like
5.3.2
or4.8.4
, beta
,latest
,next
orrc
distribution tags (opens in a new tab) of thetypescript
package.
# Run tests using TypeScript 4.9.5
tstyche --target 4.9
# Run tests using the latest version of TypeScript
tstyche --target latest
# Test on all specified versions of TypeScript
tstyche --target 4.9,5.3.2,current
--tsconfig
- Type: string
The look up strategy to be used to find the TSConfig file.
The following can be specified:
findup
, find the nearesttsconfig.json
that includes a particular test file,ignore
, do not look for anytsconfig.json
and use the defaults,- or, if a path is specified, simply load
tsconfig.json
from that path.
tstyche --tsconfig ./tsconfig.test.json
If TSConfig file is not found, or is ignored, or does not include a test file in question, the default compiler options will be set.
--update
Fetch the typescript
package metadata from the registry and exit.
The list of available TypeScript versions is updated every two hours. Use this option, if you want to force the update.
--version
Print the TSTyche version number and exit.
--watch
Watch for changes and rerun related test files. Current implementation is watching the TSTyche configuration file and the test files for changes.
Files are watched recursively using the fs.watch()
(opens in a new tab) method that relies on file system events. In some cases this feature is not available (opens in a new tab). For example, it does not work on network file systems. Also note that recursive watch support was added for the Linux systems only since Node.js 20.