From 6d438185807aa9f58f7723a716991dbd7262f378 Mon Sep 17 00:00:00 2001 From: rethab Date: Mon, 2 May 2022 15:20:01 +0200 Subject: [PATCH 1/7] chore(docs): add readme to jest-types this is to clarify the difference between @types/jest and @jest/types, see https://github.com/facebook/jest/issues/9972 --- packages/jest-types/README.md | 7 +++++++ 1 file changed, 7 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..c4768f376011 --- /dev/null +++ b/packages/jest-types/README.md @@ -0,0 +1,7 @@ +# @jest/types + +This package contains shared types of Jest's packages. + +If you're a user of Jest and looking for types, you're probably looking for [@types/jest](https://www.npmjs.com/package/@types/jest). + +See https://github.com/facebook/jest/issues/9972 for more info. From fab278021b8f6efe769964a91664328dee053417 Mon Sep 17 00:00:00 2001 From: rethab Date: Mon, 2 May 2022 16:14:04 +0200 Subject: [PATCH 2/7] suggest importing from @jest/globals --- packages/jest-types/README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md index c4768f376011..4b774632cd22 100644 --- a/packages/jest-types/README.md +++ b/packages/jest-types/README.md @@ -2,6 +2,20 @@ This package contains shared types of Jest's packages. -If you're a user of Jest and looking for types, you're probably looking for [@types/jest](https://www.npmjs.com/package/@types/jest). +If you're a user of Jest and looking for types, you could import `@jest/globals`: + +```typescript +import { describe, it, expect } from '@jest/globals'; + +describe('my tests', () => { + it('works', () => { + expect(1).toBe(1); + }); +}); +``` + +If you don't want to import types, you could install the [@types/jest](https://www.npmjs.com/package/@types/jest) package. +This is not maintained by the Jest team though. + See https://github.com/facebook/jest/issues/9972 for more info. From b34602495a49772b1d7a05b7d804924e1c1c80c2 Mon Sep 17 00:00:00 2001 From: rethab Date: Tue, 3 May 2022 09:07:31 +0200 Subject: [PATCH 3/7] Update packages/jest-types/README.md Co-authored-by: Tom Mrazauskas --- packages/jest-types/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md index 4b774632cd22..6a087805cd4b 100644 --- a/packages/jest-types/README.md +++ b/packages/jest-types/README.md @@ -2,9 +2,9 @@ This package contains shared types of Jest's packages. -If you're a user of Jest and looking for types, you could import `@jest/globals`: +If you are looking for types of [Jest globals](https://jestjs.io/docs/api), you can import them from `@jest/globals` package: -```typescript +```ts import { describe, it, expect } from '@jest/globals'; describe('my tests', () => { From 0921c7523bbb811f85eb5d8bd7e553b540d79204 Mon Sep 17 00:00:00 2001 From: rethab Date: Tue, 3 May 2022 09:08:06 +0200 Subject: [PATCH 4/7] Update packages/jest-types/README.md Co-authored-by: Tom Mrazauskas --- packages/jest-types/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md index 6a087805cd4b..b39136a03dc7 100644 --- a/packages/jest-types/README.md +++ b/packages/jest-types/README.md @@ -14,8 +14,4 @@ describe('my tests', () => { }); ``` -If you don't want to import types, you could install the [@types/jest](https://www.npmjs.com/package/@types/jest) package. -This is not maintained by the Jest team though. - - -See https://github.com/facebook/jest/issues/9972 for more info. +If you prefer to omit imports, similar result can be achieved installing the [@types/jest](https://npmjs.com/package/@types/jest) package. Note that this is third party library maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) and may not cover latest Jest features. From 06d58a9414be024351e85d6f371e1c929b07be5d Mon Sep 17 00:00:00 2001 From: rethab Date: Tue, 3 May 2022 09:09:36 +0200 Subject: [PATCH 5/7] grammar --- packages/jest-types/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md index b39136a03dc7..8556f6c9f818 100644 --- a/packages/jest-types/README.md +++ b/packages/jest-types/README.md @@ -14,4 +14,4 @@ describe('my tests', () => { }); ``` -If you prefer to omit imports, similar result can be achieved installing the [@types/jest](https://npmjs.com/package/@types/jest) package. Note that this is third party library maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) and may not cover latest Jest features. +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. From 6ac89d89d0c4b8193f81b36337f1d9e11947fc89 Mon Sep 17 00:00:00 2001 From: rethab Date: Tue, 3 May 2022 09:24:47 +0200 Subject: [PATCH 6/7] add jest config example --- packages/jest-types/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md index 8556f6c9f818..4b924ac15236 100644 --- a/packages/jest-types/README.md +++ b/packages/jest-types/README.md @@ -5,7 +5,7 @@ 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, it, expect } from '@jest/globals'; +import { describe, expect, it } from '@jest/globals'; describe('my tests', () => { it('works', () => { @@ -15,3 +15,16 @@ describe('my tests', () => { ``` 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; +``` From 895ee91454ff145702559b584dcfee8dca34e979 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 3 May 2022 09:29:36 +0200 Subject: [PATCH 7/7] prettier --- packages/jest-types/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-types/README.md b/packages/jest-types/README.md index 4b924ac15236..a4f56b6d70f7 100644 --- a/packages/jest-types/README.md +++ b/packages/jest-types/README.md @@ -5,7 +5,7 @@ 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'; +import {describe, expect, it} from '@jest/globals'; describe('my tests', () => { it('works', () => { @@ -20,7 +20,7 @@ Another use-case for `@types/jest` is a typed Jest config as those types are not ```ts // jest.config.ts -import { Config } from '@jest/types'; +import {Config} from '@jest/types'; const config: Config.InitialOptions = { // some typed config