UNPKG

949 BMarkdownView Raw
1# @jest/types
2
3This package contains shared types of Jest's packages.
4
5If you are looking for types of [Jest globals](https://jestjs.io/docs/api), you can import them from `@jest/globals` package:
6
7```ts
8import {describe, expect, it} from '@jest/globals';
9
10describe('my tests', () => {
11 it('works', () => {
12 expect(1).toBe(1);
13 });
14});
15```
16
17If you prefer to omit imports, a similar result can be achieved installing the [@types/jest](https://npmjs.com/package/@types/jest) package. Note that this is a third party library maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) and may not cover the latest Jest features.
18
19Another use-case for `@types/jest` is a typed Jest config as those types are not provided by Jest out of the box:
20
21```ts
22// jest.config.ts
23import {Config} from '@jest/types';
24
25const config: Config.InitialOptions = {
26 // some typed config
27};
28
29export default config;
30```