Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ yarn ts-jest config:init

This will create a basic Jest configuration file which will inform Jest about how to handle `.ts` files correctly.

You can also use the `jest --init` command (prefixed with either `npx` or `yarn` depending on what you're using) to have more options related to Jest.
You can also use the `create-jest` command (prefixed with either `npx` or `yarn` depending on what you're using) to have more options related to Jest.
However, answer `no` to the Jest question about whether or not to enable TypeScript. Instead, add the line: `preset: "ts-jest"` to the `jest.config.js` file afterwards.

#### Customizing
Expand Down
2 changes: 1 addition & 1 deletion website/docs/getting-started/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export type DefaultPreset = {
```ts title="jest.config.ts"
import { createDefaultLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createDefaultPreset({
const presetConfig = createDefaultLegacyPreset({
//...optionsa
})

Expand Down
8 changes: 2 additions & 6 deletions website/docs/guides/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ After that, some little modifications will be required as follows:

If you didn't yet, move any Babel config from `.babelrc` to `babel.config.js`. It should at least contain:

```ts title="jest.config.ts"
import type { Config } from 'ts-jest'

const jestConfig: Config = {
```js title="babel.config.js"
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
}

export default jestConfig
```

### TypeScript Configuration
Expand Down
26 changes: 14 additions & 12 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions website/versioned_docs/version-29.0/guides/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,17 @@ After that, some little modifications will be required as follows:

If you didn't yet, move any Babel config from `.babelrc` to `babel.config.js`. It should at least contain:

```js tab
// jest.config.js
/** @type {import('ts-jest').JestConfigWithTsJest} */
```js title="babel.config.js"
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
}
```

```ts tab
// jest.config.ts
import type { JestConfigWithTsJest } from 'ts-jest'

const jestConfig: JestConfigWithTsJest = {
presets: ['module:metro-react-native-babel-preset'],
}

export default jestConfig
```

### TypeScript Configuration

Create a new `tsconfig.spec.json` at the root of your project with the following content

```json
// tsconfig.spec.json
```json title="tsconfig.spec.json"
{
"extends": "./tsconfig.json",
"compilerOptions": {
Expand Down
53 changes: 14 additions & 39 deletions website/versioned_docs/version-29.2/getting-started/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export type DefaultPreset = {

#### Example:

```ts
// jest.config.ts
```ts title="jest.config.ts"
import { createDefaultPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createDefaultPreset({
Expand Down Expand Up @@ -123,11 +122,10 @@ export type DefaultPreset = {

#### Example:

```ts
// jest.config.ts
```ts title="jest.config.ts"
import { createDefaultLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createDefaultPreset({
const presetConfig = createDefaultLegacyPreset({
//...optionsa
})

Expand Down Expand Up @@ -182,8 +180,7 @@ export type DefaultEsmPreset = {

#### Example:

```ts
// jest.config.mts
```ts title="jest.config.ts"
import { createDefaultEsmPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createDefaultEsmPreset({
Expand Down Expand Up @@ -241,8 +238,7 @@ export type DefaultEsmPreset = {

#### Example:

```ts
// jest.config.mts
```ts title="jest.config.ts"
import { createDefaultLegacyEsmPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createDefaultLegacyEsmPreset({
Expand Down Expand Up @@ -299,8 +295,7 @@ export type JsWithTsPreset = {

#### Example:

```ts
// jest.config.ts
```ts title="jest.config.ts"
import { createJsWithTsPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithTsPreset({
Expand Down Expand Up @@ -357,8 +352,7 @@ export type JsWithTsPreset = {

#### Example:

```ts
// jest.config.ts
```ts title="jest.config.ts"
import { createJsWithTsLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithTsLegacyPreset({
Expand Down Expand Up @@ -415,8 +409,7 @@ export type JsWithTsPreset = {

#### Example:

```ts
// jest.config.mts
```ts title="jest.config.ts"
import { createJsWithTsEsmPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithTsEsmPreset({
Expand Down Expand Up @@ -473,8 +466,7 @@ export type JsWithTsPreset = {

#### Example:

```ts
// jest.config.mts
```ts title="jest.config.ts"
import { createJsWithTsEsmLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithTsEsmLegacyPreset({
Expand Down Expand Up @@ -533,8 +525,7 @@ export type JsWithBabelPreset = {

#### Example:

```ts
// jest.config.ts
```ts title="jest.config.ts"
import { createJsWithBabelPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithBabelPreset({
Expand Down Expand Up @@ -593,8 +584,7 @@ export type JsWithBabelPreset = {

#### Example:

```ts
// jest.config.ts
```ts title="jest.config.ts"
import { createJsWithBabelLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithBabelLegacyPreset({
Expand Down Expand Up @@ -653,8 +643,7 @@ export type JsWithBabelPreset = {

#### Example:

```ts
// jest.config.mts
```ts title="jest.config.ts"
import { createJsWithBabelEsmPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithBabelEsmPreset({
Expand Down Expand Up @@ -713,8 +702,7 @@ export type JsWithBabelPreset = {

#### Example:

```ts
// jest.config.mts
```ts title="jest.config.ts"
import { createJsWithBabelEsmLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createJsWithBabelEsmLegacyPreset({
Expand Down Expand Up @@ -754,20 +742,7 @@ These legacy presets will be removed in the next major release and users are **H

#### Example

```ts tab={"label": "TypeScript CJS"}
// jest.config.ts
import type { JestConfigWithTsJest } from 'ts-jest'

const jestConfig: JestConfigWithTsJest = {
// Replace `<preset_name>` with the one of the preset names from the table above
preset: '<preset_name>',
}

export default jestConfig
```

```ts tab={"label": "TypeScript ESM"}
// jest.config.mts
```ts title="jest.config.ts"
import type { JestConfigWithTsJest } from 'ts-jest'

const jestConfig: JestConfigWithTsJest = {
Expand Down
43 changes: 6 additions & 37 deletions website/versioned_docs/version-29.2/guides/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,17 @@ After that, some little modifications will be required as follows:

If you didn't yet, move any Babel config from `.babelrc` to `babel.config.js`. It should at least contain:

```js tab
// jest.config.js
/** @type {import('ts-jest').JestConfigWithTsJest} */
```js title="babel.config.js"
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
}
```

```ts tab
// jest.config.ts
import type { JestConfigWithTsJest } from 'ts-jest'

const jestConfig: JestConfigWithTsJest = {
presets: ['module:metro-react-native-babel-preset'],
}

export default jestConfig
```

### TypeScript Configuration

Create a new `tsconfig.spec.json` at the root of your project with the following content

```json
// tsconfig.spec.json
```json title="tsconfig.spec.json"
{
"extends": "./tsconfig.json",
"compilerOptions": {
Expand All @@ -48,33 +34,16 @@ Create a new `tsconfig.spec.json` at the root of your project with the following

In the same way that you moved Babel config, move Jest config from `jest` key of `package.json` to `jest.config.js`. It should look like this:

```js tab
// jest.config.js
const { createJsWithBabelPreset } = require('ts-jest')

const jsWithBabelPreset = createJsWithBabelPreset({
tsconfig: 'tsconfig.spec.json',
babelConfig: true,
})

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'react-native',
transform: jsWithBabelPreset.transform,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
```

```ts tab
// jest.config.ts
import { createJsWithBabelPreset, JestConfigWithTsJest } from 'ts-jest'
```ts title="jest.config.ts"
import type { Config } from 'jest'
import { createJsWithBabelPreset } from 'ts-jest'

const jsWithBabelPreset = createJsWithBabelPreset({
tsconfig: 'tsconfig.spec.json',
babelConfig: true,
})

const jestConfig: JestConfigWithTsJest = {
const jestConfig: Config = {
preset: 'react-native',
transform: jsWithBabelPreset.transform,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export type DefaultPreset = {
```ts title="jest.config.ts"
import { createDefaultLegacyPreset, type JestConfigWithTsJest } from 'ts-jest'

const presetConfig = createDefaultPreset({
const presetConfig = createDefaultLegacyPreset({
//...optionsa
})

Expand Down
8 changes: 2 additions & 6 deletions website/versioned_docs/version-29.3/guides/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ After that, some little modifications will be required as follows:

If you didn't yet, move any Babel config from `.babelrc` to `babel.config.js`. It should at least contain:

```ts title="jest.config.ts"
import type { Config } from 'ts-jest'

const jestConfig: Config = {
```js title="babel.config.js"
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
}

export default jestConfig
```

### TypeScript Configuration
Expand Down
Loading