From 585854fca63851a891c5be3e1381c04e341210e1 Mon Sep 17 00:00:00 2001 From: rethab Date: Tue, 3 May 2022 09:35:48 +0200 Subject: [PATCH] chore(docs): add readme to jest-types (#12791) --- packages/jest-types/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 packages/jest-types/README.md diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md new file mode 100644 index 000000000000..a4f56b6d70f7 --- /dev/null +++ b/packages/jest-types/README.md @@ -0,0 +1,30 @@ +# @jest/types + +This package contains shared types of Jest's packages. + +If you are looking for types of [Jest globals](https://jestjs.io/docs/api), you can import them from `@jest/globals` package: + +```ts +import {describe, expect, it} from '@jest/globals'; + +describe('my tests', () => { + it('works', () => { + expect(1).toBe(1); + }); +}); +``` + +If 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. + +Another use-case for `@types/jest` is a typed Jest config as those types are not provided by Jest out of the box: + +```ts +// jest.config.ts +import {Config} from '@jest/types'; + +const config: Config.InitialOptions = { + // some typed config +}; + +export default config; +```