You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `compiler` option allows you to define the compiler to be used. It'll be used to load the NodeJS module holding the TypeScript compiler.
6
+
7
+
The default value is `typescript`, which will load the original [TypeScript compiler module](https://www.npmjs.com/package/typescript). The version loaded will depend on the one installed in your project.
8
+
9
+
If you use a custom compiler, such as `ttypescript` for example, be sure its API is the same as the original TypeScript, at least for what TSJest is using.
By default TSJest uses TypeScript compiler in the context of a project (yours), with full type-checking and features. But it can also be used to compile each file separatly, as an isolated module. That's what the `isolatedModules` option (which defaults to `false`) comes for.
6
+
7
+
You'll loose type-checking ability and some features such as `const enum`, but in the case you plan on using Jest with the cache disabled (`jest --no-cache`), your tests will then run much faster.
8
+
9
+
Here is how to disable type-checking and compile each file as an isolated module:
The `tsConfig` option allows you to define the which `tsconfig` JSON file to use. An inline compiler options object can also be specified instead of the path to a file.
6
+
7
+
By default, TSJest will do like `tsc` and use the project's `tsconfig.json` file. If it cannot find one, it'l use defaults TypeScript compiler options (except `es5` is used as target instead of `es3`).
8
+
9
+
If you need to use defaults and force TSJest to use the defaults even if there is a `tsconfig.json`, you can set this option to `false`.
10
+
11
+
#### Examples
12
+
13
+
### Path to a `tsconfig` file:
14
+
15
+
The path should be relative to the current working directory where you start Jest from. You can also use `<rootDir>` in the path, or use an absolute path (this last one is strongly not recommanded).
Refer to the [TypeScript compiler options](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to know what can be used. It's basically the same that you'd put in your `tsconfig.json`'s `compilerOptions`.
By default TSJest will try to find the `tsconfig.json` in your project. But you may want to not use it at all and keep TypeScript default options. You can achieve this by setting `tsConfig` to `false`.
0 commit comments