Configuration File
The behavior of TSTyche can be customized through a configuration file.
Usage
To configure TSTyche add tstyche.config.json
file to the root of the project. Or point to your configuration file using the --config
command line option. The defaults will be used, if a configuration file is not provided.
The configuration file must contain an object. Comments, unquoted keys, single quotes or trailing commas are allowed:
{
// The list of glob patterns to match the test files
testFileMatch: [
'**/*.test.ts',
'**/*.tst.ts',
],
}
For maximum portability, examples on this page follow the JSON specification (opens in a new tab).
Schema
In-editor validation can be enabled by adding the $schema
key:
{
"$schema": "https://tstyche.org/schemas/config.json"
}
The below pattern can be used to specify the version of TSTyche:
{
"$schema": "https://tstyche.org/schemas/config-2.0.json"
}
Options
Options passed through the command line override the ones from the configuration file.
Relative paths are resolved relative to the configuration file.
Use the --showConfig
command line option to inspect the resolved configuration.
failFast
- Default:
false
- Type:
boolean
Stop running tests after the first failure.
plugins
- Default:
[]
- Type:
Array<string>
The list of plugins to use.
The following can be specified:
- name of a package:
"tstyche-plugin"
, - or a path:
"./custom-plugin.js"
.
{
"plugins": ["tstyche-plugin", "./custom-plugin.js"]
}
To learn more, see the Plugins page.
reporters
- Default:
["list", "summary"]
- Type:
Array<string>
The list of reporters to use.
The following can be specified:
- built-in reporter:
"list"
or"summary"
, - name of a package:
"tstyche-reporter"
, - or a path:
"./custom-reporter.js"
.
{
"reporters": ["list", "tstyche-reporter", "./custom-reporter.js"]
}
To learn more, see the Reporters page.
rootPath
- Default: the path to the directory from which the configuration file was loaded or the current directory
- 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 rootPath
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 rootPath
.
This means that all test files to be run and TSConfig files to load the compiler configuration from must be within the rootPath
.
For instance, if you prefer to keep the TSTyche configuration file in a ./config
directory:
- tstyche.json
The rootPath
should point to the root of the project:
{
"rootPath": "../"
}
target
- Default:
["current"]
; or["latest"]
, if TypeScript is not installed. - Type:
Array<string>
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"
or"4.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"
or"4.8.4"
, "beta"
,"latest"
,"next"
or"rc"
distribution tags (opens in a new tab) of thetypescript
package.
{
"target": ["4.9", "5.3.2", "current"]
}
testFileMatch
- Default:
["**/*.tst.*", "**/__typetests__/*.test.*", "**/typetests/*.test.*"]
- Type:
Array<string>
The list of glob patterns to match the test files. The patterns are matched with the portion of the path relative to the rootPath
directory. The matching is case insensitive.
The following rules are used when matching the patterns:
/
matches a path separator,?
matches any single character excluding path separators,*
matches zero or more characters excluding path separators,**
matches zero or more characters including path separators.
Usage examples:
?
can be used to select files or directories that differ in their name by only a character:typetests/?at.tst.ts
would matchtypetests/bat.tst.ts
ortypetests/cat.tst.ts
, but nottypetests/at.tst.ts
,*
can be used to select files within a directory:*.tst.ts
would matchOptions.tst.ts
, but notOptions.test.ts
orjson/Options.tst.ts
,**
can be used to select files within nested directories:packages/**/typetests/*.test.ts
would matchpackages/typetests/api.test.ts
,packages/core/typetests/awaitable.test.ts
orpackages/parsers/json/typetests/JsonObject.test.ts
.
The ?
, *
and **
wildcards do not match any path segments that start with the .
and do not select files within the node_modules
directories. These files or directories can only be matched, if specified explicitly: **/.generated/*.tst.*
or node_modules/**/*.tst.*
.
Use the --listFiles
command line option to inspect the list of selected files.
tsconfig
- Default:
"findup"
- 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.
{
"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.