Skip to content

Commit

Permalink
[docs] Describe the TypeScript configuration file (#3913)
Browse files Browse the repository at this point in the history
* Describe TypeScript configuration

* Rephrase a bit

* Fix path
  • Loading branch information
VasilyStrelyaev committed Jul 2, 2019
1 parent 75cd749 commit cbbe74a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/articles/documentation/test-api/typescript-support.md
Expand Up @@ -40,3 +40,38 @@ When you run a test Testcafe will output if there are any compilation errors.
> [Custom Properties](./selecting-page-elements/selectors/extending-selectors.md#custom-properties)
> and [Custom Methods](./selecting-page-elements/selectors/extending-selectors.md#custom-methods)
> sections to learn how to extend selectors in TypeScript.
## Customize Compiler Options

TestCafe allows you to specify [TypeScript compiler options](https://www.typescriptlang.org/docs/handbook/compiler-options.html) in the `tsconfig.json` file. You can use these options to enable JSX compilation, import code or typings with `paths` aliases, set aliases to React typings, or customize other compiler settings.

```json
{
"jsx": "react",
"jsxFactory": "myFactory",
"paths": {
"jquery": [ "node_modules/jquery/dist/jquery" ]
},
"alwaysStrict": true
}
```

See the available options in the [TypeScript Compiler Options](https://www.typescriptlang.org/docs/handbook/compiler-options.html) topic.

> Important! You cannot override the `module` and `target` options.
Save `tsconfig.json` to the directory from which you run TestCafe (usually the project's root directory), or specify the [tsConfigPath](../using-testcafe/configuration-file.md#tsconfigpath) option in the [configuration file](../using-testcafe/configuration-file.md) to use a different location.

> `tsconfig.json` supports [JSON5 syntax](https://json5.org/). This allows you to use JavaScript identifiers as object keys, single-quoted strings, comments and other JSON5 features.
TestCafe passes the following options to the TypeScript compiler unless you override them in `tsconfig.json`:

Option | Value
------------------------- | ------
`allowJs` | `true`
`emitDecoratorMetadata` | `true`
`experimentalDecorators` | `true`
`inlineSourceMap` | `true`
`noImplicitAny` | `false`
`pretty` | `true`
`suppressOutputPathCheck` | `true`
15 changes: 15 additions & 0 deletions docs/articles/documentation/using-testcafe/configuration-file.md
Expand Up @@ -49,6 +49,7 @@ A configuration file can include the following settings:
* [developmentMode](#developmentmode)
* [qrCode](#qrcode)
* [stopOnFirstFail](#stoponfirstfail)
* [tsConfigPath](#tsconfigpath)
* [color](#color)
* [noColor](#nocolor)

Expand Down Expand Up @@ -745,6 +746,20 @@ Stops a test run if any test fails.
*CLI*: [--sf, --stop-on-first-fail](command-line-interface.md#--sf---stop-on-first-fail)
*API*: [runner.run({ stopOnFirstFail })](programming-interface/runner.md#run)

## tsConfigPath

Specifies the [TypeScript configuration file](../test-api/typescript-support.md#customize-compiler-options) location.

```json
{
"tsConfigPath": "/Users/s.johnson/testcafe/tsconfig.json"
}
```

You can specify an absolute or relative path. Relative paths resolve from the current directory (the directory from which you run TestCafe).

If the `tsConfigPath` option is not specified, TestCafe looks for the `tsconfig.json` file in the current directory.

## color

Enables colors in the command line.
Expand Down
1 change: 1 addition & 0 deletions examples/.testcaferc.json
Expand Up @@ -54,6 +54,7 @@
"pfx": "path/to/file.pfx",
"rejectUnauthorized": true
},
"tsConfigPath": "/Users/s.johnson/testcafe/tsconfig.json",
"developmentMode": true,
"qrCode": true
}

0 comments on commit cbbe74a

Please sign in to comment.