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 matching test file
tstyche query-params
# Test against specific versions of TypeScript
tstyche --target '5.4 || 5.6.2 || >=5.8'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.
Use the --showConfig command line option to inspect the resolved configuration.
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:
--reporters 'list, summary'.
Relative paths are resolved relative to the current directory.
--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.
--fetch
Fetch the specified versions of the typescript package and exit.
--fetch 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.
tstyche --fetch --target '5.5 || >=5.8'--help
Print the list of command line options with brief descriptions and exit.
--list
Print the list of supported versions of the typescript package and exit.
--listFiles
Print the list of 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 fetched versions the typescript package and exit.
--quiet
- Type: boolean
Silence all test runner output except errors and warnings.
--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.jsTo learn more, see the Reporters page.
--root
- Type: string
The path to a directory containing files of a test project.
To collect the test files, the file tree is walked starting from the root directory. Later during the test run, the lookup of tsconfig.json for each test file starts at the directory containing the file and ends at the root directory.
This means that all test files to be run and TSConfig files to load the compiler configuration from must be within the root directory.
When the --root command line option is set, the configuration file is searched for in that directory. To avoid this, set an explicit --config path as well:
tstyche --config ./tstyche.json --root ./example--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: string
The range of TypeScript versions test against.
The following can be specified:
- minor releases, like
5.6, resolves to the latest version in the series (for example,5.6resolves to version 5.6.3), - patch releases, like
5.8.2, beta,latest,nextorrcdistribution tags of thetypescriptpackage.
To specify multiple versions, provide a single string with versions separated by ||:
tstyche --target '5.6 || 5.8.2 || latest'Ranges
Version ranges allow testing on a range of TypeScript versions. The range must be specified using an operator and a minor version.
Supported operators:
>, greater than,>=, greater than or equal,<, less than,<=, less than or equal.
For example, the range >=5.5 gets expanded to: 5.5, 5.6, 5.7 and so on. In the future this list will include newly released versions as well.
To set an upper bound, the intersection of two ranges can be used: >=5.4 <5.6. Here only 5.4 and 5.5 are included.
Ranges and versions can be combined:
tstyche --target '>=5.4 <5.6 || 5.6.2 || >=5.7'Use the --list command line option to inspect the list of supported versions.
--tsconfig
- Type: string
The look up strategy to be used to find the TSConfig file.
The following can be specified:
findup, find the nearesttsconfig.jsonthat includes a particular test file,ignore, do not look for anytsconfig.jsonand use default compiler options,- or, if a path is specified, load
tsconfig.jsonfrom that path.
tstyche --tsconfig ./tsconfig.test.jsonIf TSConfig file does not include a test file in question, default compiler options are 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.
--verbose
- Type: boolean
Enable detailed logging.
--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() method that relies on file system events. In some cases this feature is not available . For example, it does not work on network file systems.