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
feat(presets): add 3 new presets to work with ESM (#2207)
BREAKING CHANGE
- `create-jest-preset` util function signature has changed to
```
function createJestPreset(allowJs?: boolean, extraOptions?: Config.InitialOptions): TsJestPresets;
```
It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript`**vs** TypeScript (and `ts-jest`)](https://kulshekhar.github.io/ts-jest/user/babel7-or-ts).
17
+
It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript`**vs** TypeScript (and `ts-jest`)](https://kulshekhar.github.io/ts-jest/docs/babel7-or-ts).
Copy file name to clipboardexpand all lines: docs/docs/presets.md
+9-6
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,18 @@ id: presets
3
3
title: Presets
4
4
---
5
5
6
-
### The 3 presets
6
+
### The presets
7
7
8
-
`ts-jest` comes with 3 presets, covering most of the project's base configuration:
8
+
`ts-jest` comes with several presets, covering most of the project's base configuration:
9
9
10
10
| Preset name | Description |
11
11
|---|---|
12
-
|`ts-jest/presets/default`<br/>or `ts-jest`|`ts-jest` will take care of `.ts` and `.tsx` files only, leaving JavaScript files as-is. |
13
-
|`ts-jest/presets/js-with-ts`| TypeScript and JavaScript files (`.ts`, `.tsx`, `.js` and `.jsx`) will be handled by `ts-jest`.<br/>You'll need to set `allowJs` to `true` in your `tsconfig.json` file. |
14
-
|`ts-jest/presets/js-with-babel`| TypeScript files will be handled by `ts-jest`, and JavaScript files will be handled by `babel-jest`. |
12
+
|`ts-jest/presets/default`<br/>or `ts-jest`| TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **CommonJS** syntax, leaving JavaScript files (`.js`, `jsx`) as-is. |
13
+
|`ts-jest/presets/default-esm`<br/> | TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **ESM** syntax, leaving JavaScript files (`.js`, `jsx`) as-is. |
14
+
|`ts-jest/presets/js-with-ts`| TypeScript and JavaScript files (`.ts`, `.tsx`, `.js`, `.jsx`) will be transformed by `ts-jest` to **CommonJS** syntax.<br/>You'll need to set `allowJs` to `true` in your `tsconfig.json` file. |
15
+
|`ts-jest/presets/js-with-ts-esm`| TypeScript and JavaScript files (`.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`) will be transformed by `ts-jest` to **ESM** syntax.<br/>You'll need to set `allowJs` to `true` in your `tsconfig.json` file. |
16
+
|`ts-jest/presets/js-with-babel`| TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **CommonJS** syntax, and JavaScript files (`.js`, `jsx`) will be transformed by `babel-jest`. |
17
+
|`ts-jest/presets/js-with-babel-esm`| TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **ESM** syntax, and JavaScript files (`.js`, `jsx`, `.mjs`) will be transformed by `babel-jest`. |
0 commit comments