Skip to content

Commit 6fc1860

Browse files
authored
docs: improve TypeScript Usage documentation with few additional notes (#13601)
1 parent 05deb83 commit 6fc1860

20 files changed

+60
-30
lines changed

docs/GettingStarted.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ In order for Jest to transpile TypeScript with `ts-jest`, you may also need to c
168168

169169
There are two ways to have [Jest global APIs](GlobalAPI.md) typed for test files written in TypeScript.
170170

171-
You can use type definitions which ships with Jest and will update each time you update Jest. Simply import the APIs from `@jest/globals` package:
171+
You can use type definitions which ships with Jest and will update each time you update Jest. Install the `@jest/globals` package:
172+
173+
```bash npm2yarn
174+
npm install --save-dev @jest/globals
175+
```
176+
177+
And import the APIs from it:
172178

173179
```ts title="sum.test.ts"
174180
import {describe, expect, test} from '@jest/globals';

docs/GlobalAPI.md

+2
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ test.todo('add should be associative');
973973

974974
## TypeScript Usage
975975

976+
<TypeScriptExamplesNote />
977+
976978
### `.each`
977979

978980
The `.each` modifier offers few different ways to define a table of the test cases. Some of the APIs have caveats related with the type inference of the arguments which are passed to `describe` or `test` callback functions. Let's take a look at each of them.

docs/MockFunctionAPI.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ test('async test', async () => {
517517

518518
## TypeScript Usage
519519

520-
:::tip
521-
522-
Please consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
523-
524-
:::
520+
<TypeScriptExamplesNote />
525521

526522
### `jest.fn(implementation?)`
527523

docs/_TypeScriptExamplesNote.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ The TypeScript examples from this page will only work as documented if you expli
66
import {expect, jest, test} from '@jest/globals';
77
```
88

9+
Consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
10+
911
:::

website/versioned_docs/version-29.0/GettingStarted.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ In order for Jest to transpile TypeScript with `ts-jest`, you may also need to c
164164

165165
There are two ways to have [Jest global APIs](GlobalAPI.md) typed for test files written in TypeScript.
166166

167-
You can use type definitions which ships with Jest and will update each time you update Jest. Simply import the APIs from `@jest/globals` package:
167+
You can use type definitions which ships with Jest and will update each time you update Jest. Install the `@jest/globals` package:
168+
169+
```bash npm2yarn
170+
npm install --save-dev @jest/globals
171+
```
172+
173+
And import the APIs from it:
168174

169175
```ts title="sum.test.ts"
170176
import {describe, expect, test} from '@jest/globals';

website/versioned_docs/version-29.0/GlobalAPI.md

+2
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ test.todo('add should be associative');
973973

974974
## TypeScript Usage
975975

976+
<TypeScriptExamplesNote />
977+
976978
### `.each`
977979

978980
The `.each` modifier offers few different ways to define a table of the test cases. Some of the APIs have caveats related with the type inference of the arguments which are passed to `describe` or `test` callback functions. Let's take a look at each of them.

website/versioned_docs/version-29.0/MockFunctionAPI.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,7 @@ test('async test', async () => {
480480

481481
## TypeScript Usage
482482

483-
:::tip
484-
485-
Please consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
486-
487-
:::
483+
<TypeScriptExamplesNote />
488484

489485
### `jest.fn(implementation?)`
490486

website/versioned_docs/version-29.0/_TypeScriptExamplesNote.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ The TypeScript examples from this page will only work as documented if you expli
66
import {expect, jest, test} from '@jest/globals';
77
```
88

9+
Consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
10+
911
:::

website/versioned_docs/version-29.1/GettingStarted.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ In order for Jest to transpile TypeScript with `ts-jest`, you may also need to c
168168

169169
There are two ways to have [Jest global APIs](GlobalAPI.md) typed for test files written in TypeScript.
170170

171-
You can use type definitions which ships with Jest and will update each time you update Jest. Simply import the APIs from `@jest/globals` package:
171+
You can use type definitions which ships with Jest and will update each time you update Jest. Install the `@jest/globals` package:
172+
173+
```bash npm2yarn
174+
npm install --save-dev @jest/globals
175+
```
176+
177+
And import the testing APIs from it:
172178

173179
```ts title="sum.test.ts"
174180
import {describe, expect, test} from '@jest/globals';

website/versioned_docs/version-29.1/GlobalAPI.md

+2
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ test.todo('add should be associative');
973973

974974
## TypeScript Usage
975975

976+
<TypeScriptExamplesNote />
977+
976978
### `.each`
977979

978980
The `.each` modifier offers few different ways to define a table of the test cases. Some of the APIs have caveats related with the type inference of the arguments which are passed to `describe` or `test` callback functions. Let's take a look at each of them.

website/versioned_docs/version-29.1/MockFunctionAPI.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ test('async test', async () => {
517517

518518
## TypeScript Usage
519519

520-
:::tip
521-
522-
Please consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
523-
524-
:::
520+
<TypeScriptExamplesNote />
525521

526522
### `jest.fn(implementation?)`
527523

website/versioned_docs/version-29.1/_TypeScriptExamplesNote.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ The TypeScript examples from this page will only work as documented if you expli
66
import {expect, jest, test} from '@jest/globals';
77
```
88

9+
Consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
10+
911
:::

website/versioned_docs/version-29.2/GettingStarted.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ In order for Jest to transpile TypeScript with `ts-jest`, you may also need to c
168168

169169
There are two ways to have [Jest global APIs](GlobalAPI.md) typed for test files written in TypeScript.
170170

171-
You can use type definitions which ships with Jest and will update each time you update Jest. Simply import the APIs from `@jest/globals` package:
171+
You can use type definitions which ships with Jest and will update each time you update Jest. Install the `@jest/globals` package:
172+
173+
```bash npm2yarn
174+
npm install --save-dev @jest/globals
175+
```
176+
177+
And import the testing APIs from it:
172178

173179
```ts title="sum.test.ts"
174180
import {describe, expect, test} from '@jest/globals';

website/versioned_docs/version-29.2/GlobalAPI.md

+2
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ test.todo('add should be associative');
973973

974974
## TypeScript Usage
975975

976+
<TypeScriptExamplesNote />
977+
976978
### `.each`
977979

978980
The `.each` modifier offers few different ways to define a table of the test cases. Some of the APIs have caveats related with the type inference of the arguments which are passed to `describe` or `test` callback functions. Let's take a look at each of them.

website/versioned_docs/version-29.2/MockFunctionAPI.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ test('async test', async () => {
517517

518518
## TypeScript Usage
519519

520-
:::tip
521-
522-
Please consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
523-
524-
:::
520+
<TypeScriptExamplesNote />
525521

526522
### `jest.fn(implementation?)`
527523

website/versioned_docs/version-29.2/_TypeScriptExamplesNote.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ The TypeScript examples from this page will only work as documented if you expli
66
import {expect, jest, test} from '@jest/globals';
77
```
88

9+
Consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
10+
911
:::

website/versioned_docs/version-29.3/GettingStarted.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ In order for Jest to transpile TypeScript with `ts-jest`, you may also need to c
168168

169169
There are two ways to have [Jest global APIs](GlobalAPI.md) typed for test files written in TypeScript.
170170

171-
You can use type definitions which ships with Jest and will update each time you update Jest. Simply import the APIs from `@jest/globals` package:
171+
You can use type definitions which ships with Jest and will update each time you update Jest. Install the `@jest/globals` package:
172+
173+
```bash npm2yarn
174+
npm install --save-dev @jest/globals
175+
```
176+
177+
And import the testing APIs from it:
172178

173179
```ts title="sum.test.ts"
174180
import {describe, expect, test} from '@jest/globals';

website/versioned_docs/version-29.3/GlobalAPI.md

+2
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ test.todo('add should be associative');
973973

974974
## TypeScript Usage
975975

976+
<TypeScriptExamplesNote />
977+
976978
### `.each`
977979

978980
The `.each` modifier offers few different ways to define a table of the test cases. Some of the APIs have caveats related with the type inference of the arguments which are passed to `describe` or `test` callback functions. Let's take a look at each of them.

website/versioned_docs/version-29.3/MockFunctionAPI.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ test('async test', async () => {
517517

518518
## TypeScript Usage
519519

520-
:::tip
521-
522-
Please consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
523-
524-
:::
520+
<TypeScriptExamplesNote />
525521

526522
### `jest.fn(implementation?)`
527523

website/versioned_docs/version-29.3/_TypeScriptExamplesNote.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ The TypeScript examples from this page will only work as documented if you expli
66
import {expect, jest, test} from '@jest/globals';
77
```
88

9+
Consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
10+
911
:::

0 commit comments

Comments
 (0)