From 8cab7e723927181215a420b6eb9c785ee219051b Mon Sep 17 00:00:00 2001 From: cpojer Date: Sat, 2 May 2020 12:33:09 +0100 Subject: [PATCH 01/18] Add Jest 26 blog post --- website/blog/2020-05-06-jest-26.md | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 website/blog/2020-05-06-jest-26.md diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md new file mode 100644 index 000000000000..f22a34640e56 --- /dev/null +++ b/website/blog/2020-05-06-jest-26.md @@ -0,0 +1,47 @@ +--- +title: Jest 26: Tick Tock +author: Christoph Nakazawa +authorURL: http://twitter.com/cpojer +authorFBID: 100000023028168 +--- + +# Jest 26: Tick Tock + +When we started rebuilding Jest five years ago our goal was to provide a batteries-included zero-configuration test runner that is approachable for beginners, extensible for almost all testing use cases and scalable to large projects. One of the most important releases was [Jest 15](https://jestjs.io/blog/2016/09/01/jest-15) which tied all the bits and pieces together and provided great defaults that allowed people to install and run Jest often without any setup. However, this approach has a big downside as Jest installs a lot of dependencies into your projects that you may not need. + +We are now beginning to address this shortcoming and are working on reducing Jest’s install size while keeping it approachable and extensible. We have made the following breaking changes in Jest 26: + + + +* `[expect, jest-mock, pretty-format]` Remove `build-es5` from all packages ([#9945](https://github.com/facebook/jest/pull/9945)) +* `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943)) +* TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/facebook/jest/pull/9823)) + +With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -> 3.1 MiB). + +While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): + +* Jest 27 will ship with a new test runner (`jest-circus`), new fake timers with Lolex and the node.js environment by default. `jest-jasmine2`, the previous FakeTimers implementation and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. +* Jest 28 will remove `jest-jasmine2`, FakeTimers and `jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. + +Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new architecture now you can upgrade to Jest 26 and add the following configuration options: + +``` +TODO Simen/jeysal: configuration example +``` + +## Other Breaking Changes in Jest 26 + +* Dropped support for Node 8 ([#9423](https://github.com/facebook/jest/pull/9423)) +* `[jest-environment-jsdom]` Upgrade `jsdom` to v16 ([#9606](https://github.com/facebook/jest/pull/9606)) +* `[jest-runtime]` Remove long-deprecated `require.requireActual` and `require.requireMock` methods ([#9854](https://github.com/facebook/jest/pull/9854)) +* `[jest-haste-map]` Removed `providesModuleNodeModules` ([#8535](https://github.com/facebook/jest/pull/8535)) +* `[jest-circus]` Fail tests if a test takes a done callback and have return values ([#9129](https://github.com/facebook/jest/pull/9129)) +* `[jest-circus]` Throw a proper error if a test / hooks is defined asynchronously ([#8096](https://github.com/facebook/jest/pull/8096)) +* ***TODO*** + +## Stay Safe + +We are all currently experiencing an unprecedented time in recent history. If you were recently laid off because of the ongoing pandemic and are struggling, we are happy to support you using [Jest’s OpenCollective fund](https://opencollective.com/jest). Check out this list of tasks and comment on the ones you’d like to work on to get started. + +Please stay safe. From 244885b2b9d165caffb0891ea69ee6d373473611 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 3 May 2020 18:13:40 +0100 Subject: [PATCH 02/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Orta --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index f22a34640e56..06f185a79341 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -13,7 +13,7 @@ We are now beginning to address this shortcoming and are working on reducing Jes -* `[expect, jest-mock, pretty-format]` Remove `build-es5` from all packages ([#9945](https://github.com/facebook/jest/pull/9945)) +* `[expect, jest-mock, pretty-format]` Remove `es5` build files from with a new minimum of support of ES2015 (Node 8) - the es5 build files were only for browsers. ([#9945](https://github.com/facebook/jest/pull/9945)) * `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943)) * TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/facebook/jest/pull/9823)) From 03dd5884a9c74c1258cdf3036c0985a479b81a74 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 3 May 2020 18:13:55 +0100 Subject: [PATCH 03/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Orta --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 06f185a79341..1028bd82aca7 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -19,7 +19,7 @@ We are now beginning to address this shortcoming and are working on reducing Jes With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -> 3.1 MiB). -While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): +While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and it's dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): * Jest 27 will ship with a new test runner (`jest-circus`), new fake timers with Lolex and the node.js environment by default. `jest-jasmine2`, the previous FakeTimers implementation and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. * Jest 28 will remove `jest-jasmine2`, FakeTimers and `jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. From e192cf4d13e037391d3efca29ec3fc3204e220c2 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 3 May 2020 18:14:13 +0100 Subject: [PATCH 04/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Orta --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 1028bd82aca7..a13dc024c18b 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -42,6 +42,6 @@ TODO Simen/jeysal: configuration example ## Stay Safe -We are all currently experiencing an unprecedented time in recent history. If you were recently laid off because of the ongoing pandemic and are struggling, we are happy to support you using [Jest’s OpenCollective fund](https://opencollective.com/jest). Check out this list of tasks and comment on the ones you’d like to work on to get started. +We are all currently experiencing an unprecedented time of uncertainty. If you are struggling financially, we would like to use [Jest’s OpenCollective fund](https://opencollective.com/jest) to help new and existing contributors. We have an existing [list of issues with a bounty](https://github.com/facebook/jest/issues?q=is%3Aissue+is%3Aopen+bounty+label%3A%22Has+Bounty%22) but are open to offering a bounty on any of our current open issues - you can mention that this issue should have a bounty in the issue or contact us privately via _x_. Please stay safe. From ea61f2720b7839d8c3f9036bee5b7f9cf4fcdf83 Mon Sep 17 00:00:00 2001 From: cpojer Date: Sun, 3 May 2020 19:34:02 +0100 Subject: [PATCH 05/18] Comments --- website/blog/2020-05-06-jest-26.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index a13dc024c18b..d4ada855b30c 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -13,22 +13,29 @@ We are now beginning to address this shortcoming and are working on reducing Jes -* `[expect, jest-mock, pretty-format]` Remove `es5` build files from with a new minimum of support of ES2015 (Node 8) - the es5 build files were only for browsers. ([#9945](https://github.com/facebook/jest/pull/9945)) +* `[expect, jest-mock, pretty-format]` Remove `ES5` build files with a new minimum of support of ES2015 (Node 8) which were only used for browser builds ([#9945](https://github.com/facebook/jest/pull/9945)) * `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943)) * TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/facebook/jest/pull/9823)) With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -> 3.1 MiB). -While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and it's dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): +While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): * Jest 27 will ship with a new test runner (`jest-circus`), new fake timers with Lolex and the node.js environment by default. `jest-jasmine2`, the previous FakeTimers implementation and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. -* Jest 28 will remove `jest-jasmine2`, FakeTimers and `jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. +* Jest 28 will remove `jest-jasmine2` and `jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new architecture now you can upgrade to Jest 26 and add the following configuration options: +```json +{ + "jest": { + "testEnvironment": "jsdom", + "testRunner": "jest-circus/runner" + } +} ``` -TODO Simen/jeysal: configuration example -``` + +Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JS syntax to something understood by current versions of Node.js and browsers. It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for V8 coverage and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. ## Other Breaking Changes in Jest 26 @@ -42,6 +49,6 @@ TODO Simen/jeysal: configuration example ## Stay Safe -We are all currently experiencing an unprecedented time of uncertainty. If you are struggling financially, we would like to use [Jest’s OpenCollective fund](https://opencollective.com/jest) to help new and existing contributors. We have an existing [list of issues with a bounty](https://github.com/facebook/jest/issues?q=is%3Aissue+is%3Aopen+bounty+label%3A%22Has+Bounty%22) but are open to offering a bounty on any of our current open issues - you can mention that this issue should have a bounty in the issue or contact us privately via _x_. +We are all currently experiencing an unprecedented time of uncertainty. If you are struggling financially, we would like to use [Jest’s OpenCollective fund](https://opencollective.com/jest) to help new and existing contributors. We have an existing [list of issues with a bounty](https://github.com/facebook/jest/issues?q=is%3Aissue+is%3Aopen+bounty+label%3A%22Has+Bounty%22) but are open to offering a bounty on any of our current open issues - you can mention that this issue should have a bounty in the issue or contact [@cpojer via private message on Twitter](https://twitter.com/cpojer). Please stay safe. From c2b85f4c2a37a977449890f3526ec94faeb007b7 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 3 May 2020 19:34:23 +0100 Subject: [PATCH 06/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Simen Bekkhus --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index d4ada855b30c..3e60ca80d04f 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -21,7 +21,7 @@ With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): -* Jest 27 will ship with a new test runner (`jest-circus`), new fake timers with Lolex and the node.js environment by default. `jest-jasmine2`, the previous FakeTimers implementation and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. +* Jest 27 will ship with a new test runner (`jest-circus`) and the node.js environment by default. `jest-jasmine2` and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. * Jest 28 will remove `jest-jasmine2` and `jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new architecture now you can upgrade to Jest 26 and add the following configuration options: From 5bf935d20740177570bfdf681c465e92a59cc77d Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 3 May 2020 20:09:28 +0100 Subject: [PATCH 07/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Simen Bekkhus --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 3e60ca80d04f..50ba9a1294d3 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -29,7 +29,7 @@ Upon upgrading to these major releases, Jest will guide you through the necessar ```json { "jest": { - "testEnvironment": "jsdom", + "testEnvironment": "node", "testRunner": "jest-circus/runner" } } From b665e13e0cf18f0cc2127877cd2f0a6a1b0a503c Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Mon, 4 May 2020 21:45:48 +0100 Subject: [PATCH 08/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Tim Seckinger --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 50ba9a1294d3..e59707255341 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -22,7 +22,7 @@ With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): * Jest 27 will ship with a new test runner (`jest-circus`) and the node.js environment by default. `jest-jasmine2` and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. -* Jest 28 will remove `jest-jasmine2` and `jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. +* Jest 28 will remove `jest-jasmine2` and `jest-environment-jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new architecture now you can upgrade to Jest 26 and add the following configuration options: From 38776e99b761b65eb0d185c8ff4eb2d8bf31a049 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Mon, 4 May 2020 21:46:02 +0100 Subject: [PATCH 09/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Tim Seckinger --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index e59707255341..320af3073f26 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -21,7 +21,7 @@ With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): -* Jest 27 will ship with a new test runner (`jest-circus`) and the node.js environment by default. `jest-jasmine2` and `jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. +* Jest 27 will ship with a new test runner (`jest-circus`) and the Node.js environment by default. `jest-jasmine2` and `jest-environment-jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. * Jest 28 will remove `jest-jasmine2` and `jest-environment-jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new architecture now you can upgrade to Jest 26 and add the following configuration options: From 546c76e2644067e8acf32bd94dc91f3494c4ef93 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Mon, 4 May 2020 21:46:53 +0100 Subject: [PATCH 10/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Tim Seckinger --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 320af3073f26..8680ef093387 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -24,7 +24,7 @@ While this is a good start, it isn’t enough to make Jest meaningfully leaner. * Jest 27 will ship with a new test runner (`jest-circus`) and the Node.js environment by default. `jest-jasmine2` and `jest-environment-jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. * Jest 28 will remove `jest-jasmine2` and `jest-environment-jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. -Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new architecture now you can upgrade to Jest 26 and add the following configuration options: +Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new defaults now, and your project does not require a DOM environment, you can upgrade to Jest 26 and add the following configuration options: ```json { From ef5fdedd49c821758a9abc3c9bbdc7b53df9eb2c Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Mon, 4 May 2020 21:47:22 +0100 Subject: [PATCH 11/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Tim Seckinger --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 8680ef093387..f276f6666570 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -49,6 +49,6 @@ Jest will continue to ship with `babel-jest` enabled by default. It currently po ## Stay Safe -We are all currently experiencing an unprecedented time of uncertainty. If you are struggling financially, we would like to use [Jest’s OpenCollective fund](https://opencollective.com/jest) to help new and existing contributors. We have an existing [list of issues with a bounty](https://github.com/facebook/jest/issues?q=is%3Aissue+is%3Aopen+bounty+label%3A%22Has+Bounty%22) but are open to offering a bounty on any of our current open issues - you can mention that this issue should have a bounty in the issue or contact [@cpojer via private message on Twitter](https://twitter.com/cpojer). +We are all currently experiencing an unprecedented time of uncertainty. If you are struggling financially, we would like to use [Jest’s Open Collective fund](https://opencollective.com/jest) to help new and existing contributors. We place [bounties on some issues](https://github.com/facebook/jest/issues?q=is%3Aissue+is%3Aopen+bounty+label%3A%22Has+Bounty%22) and are open to offering a bounty on any of our current open issues - you can mention that an issue should have a bounty in the issue or contact [@cpojer via private message on Twitter](https://twitter.com/cpojer). Please stay safe. From 1165de35cf12c3c6b2c3fb26a385e1b216281288 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 5 May 2020 13:40:07 +0100 Subject: [PATCH 12/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Simen Bekkhus --- website/blog/2020-05-06-jest-26.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index f276f6666570..24a0e2f1aa58 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -35,7 +35,7 @@ Upon upgrading to these major releases, Jest will guide you through the necessar } ``` -Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JS syntax to something understood by current versions of Node.js and browsers. It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for V8 coverage and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. +Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for [V8 coverage](/blog/2020/01/21/jest-25#v8-code-coverage) and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. ## Other Breaking Changes in Jest 26 From 2caee7c2a2f8c73bc982bd50abf1876a5314957e Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 5 May 2020 16:52:47 +0100 Subject: [PATCH 13/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Simen Bekkhus --- website/blog/2020-05-06-jest-26.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 24a0e2f1aa58..49ab13d6b980 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -36,7 +36,17 @@ Upon upgrading to these major releases, Jest will guide you through the necessar ``` Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for [V8 coverage](/blog/2020/01/21/jest-25#v8-code-coverage) and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. +## New implementation of fake timers +Since 2017 we've been wanting to swap out Jest's implementation of fake timer with the more feature-complete implementation of Lolex - with Jest 26 this is finally happening! It took so long Lolex has even been renamed in the meantime to `@sinonjs/fake-timers`. It has taken so long since we wanted to make sure the implementation was solid and was usable for all the use cases Jest already supported. We're now confident it is stable enough for everybody to use. + +The new implementation comes with some extra features, such as mocking `Date`, `queueMicrotask` and more, see their [readme](https://github.com/sinonjs/fake-timers/blob/master/README.md) for more details. We're calling the APIs through the Jest APIs you already know, so keep calling `jest.runAllTimers()` etc. like you've been doing. The docs as always are available [here](https://jestjs.io/docs/en/timer-mocks) on our website. + +While we are confident this implementation is ready for prime time, we don't want to force people to rewrite their tests if they depend on Jest's current implementation to work, so for Jest 26 this new implementation will remain _opt-in_. Activate it by calling `jest.useFakeTimers('modern')` or by passing `modern` as the option in your config if you currently have `fake` there. + +We will continue to support the legacy implementation going forward, but we will swap the default over to the "modern" timers in Jest 27. At that time you can opt-in to the legacy implementation by specifying `jest.useFakeTimers('legacy')`. If you know _now_ that you want to keep using the legacy implementation, you can specify that today and not have to change anything when Jest 27 comes around. + +Huge thanks to [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! ## Other Breaking Changes in Jest 26 * Dropped support for Node 8 ([#9423](https://github.com/facebook/jest/pull/9423)) From 1d4ed4def5a86e213bcf4f43238b6760fc1cdc9b Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 5 May 2020 16:52:59 +0100 Subject: [PATCH 14/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Simen Bekkhus --- website/blog/2020-05-06-jest-26.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 49ab13d6b980..3aac19f235c0 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -37,7 +37,9 @@ Upon upgrading to these major releases, Jest will guide you through the necessar Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for [V8 coverage](/blog/2020/01/21/jest-25#v8-code-coverage) and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. ## New implementation of fake timers +## Native ESM support +As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modules-support) we have begun exploring native support for ECMAScript Modules. This work started shipping in Jest 25.3, and has received bug fixes and features in every release since. We're still some distance away from it stabilizing, but any and all help testing it would be highly appreciated! For an overview of the current state you can check out [this issue](https://github.com/facebook/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/facebook/jest/labels/ES%20Modules). Since 2017 we've been wanting to swap out Jest's implementation of fake timer with the more feature-complete implementation of Lolex - with Jest 26 this is finally happening! It took so long Lolex has even been renamed in the meantime to `@sinonjs/fake-timers`. It has taken so long since we wanted to make sure the implementation was solid and was usable for all the use cases Jest already supported. We're now confident it is stable enough for everybody to use. The new implementation comes with some extra features, such as mocking `Date`, `queueMicrotask` and more, see their [readme](https://github.com/sinonjs/fake-timers/blob/master/README.md) for more details. We're calling the APIs through the Jest APIs you already know, so keep calling `jest.runAllTimers()` etc. like you've been doing. The docs as always are available [here](https://jestjs.io/docs/en/timer-mocks) on our website. From bc844800c7eaa976298b494682f0c753ad1b2220 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 5 May 2020 16:53:12 +0100 Subject: [PATCH 15/18] Update website/blog/2020-05-06-jest-26.md Co-authored-by: Simen Bekkhus --- website/blog/2020-05-06-jest-26.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 3aac19f235c0..0dd2f49b2f9e 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -38,7 +38,19 @@ Upon upgrading to these major releases, Jest will guide you through the necessar Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for [V8 coverage](/blog/2020/01/21/jest-25#v8-code-coverage) and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. ## New implementation of fake timers ## Native ESM support +## New way to consume Jest - `@jest/globals` +Jest has used the widely known `describe`, `it`, `test` and `expect` globals throughout its lifetime - it's a widely used pattern, it's very easy to get started quickly and we all like the ease globals offers us when writing code. That said, we've heard (loud and clear) that many people don't like globals and that they'd like to import the functions in their tests instead. + +With Jest 26*, this is now a possibility through the use of a new package called `@jest/globals`. So now you can do `import { expect, jest, test } from '@jest/globals';` in your tests to your heart's content! + +A couple of quick caveats: + +1. The globals still exist in the environment - we will introduce a `noGlobals` mode in the future for those who wants no globals whatsoever +1. There's currently no clean way to add custom matchers to the TypeScript definitions. Help appreciated fixing that. +1. If you do `const {jest} = require('@jest/globals')` - i.e. don't use transpiled (or native) `import` syntax, you will get declaration errors as we still inject `jest` into the module scope of every file. The `noGlobals` mode will alleviate this issue + +*) This was released in 25.5, but we didn't blog about it! As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modules-support) we have begun exploring native support for ECMAScript Modules. This work started shipping in Jest 25.3, and has received bug fixes and features in every release since. We're still some distance away from it stabilizing, but any and all help testing it would be highly appreciated! For an overview of the current state you can check out [this issue](https://github.com/facebook/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/facebook/jest/labels/ES%20Modules). Since 2017 we've been wanting to swap out Jest's implementation of fake timer with the more feature-complete implementation of Lolex - with Jest 26 this is finally happening! It took so long Lolex has even been renamed in the meantime to `@sinonjs/fake-timers`. It has taken so long since we wanted to make sure the implementation was solid and was usable for all the use cases Jest already supported. We're now confident it is stable enough for everybody to use. From 01d916ab77e17420f90832d519aa2a42a30b7468 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 5 May 2020 18:23:41 +0200 Subject: [PATCH 16/18] fix heading placements --- website/blog/2020-05-06-jest-26.md | 50 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 0dd2f49b2f9e..d7d928a9efd7 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -13,16 +13,16 @@ We are now beginning to address this shortcoming and are working on reducing Jes -* `[expect, jest-mock, pretty-format]` Remove `ES5` build files with a new minimum of support of ES2015 (Node 8) which were only used for browser builds ([#9945](https://github.com/facebook/jest/pull/9945)) -* `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943)) -* TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/facebook/jest/pull/9823)) +- `[expect, jest-mock, pretty-format]` Remove `ES5` build files with a new minimum of support of ES2015 (Node 8) which were only used for browser builds ([#9945](https://github.com/facebook/jest/pull/9945)) +- `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943)) +- TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/facebook/jest/pull/9823)) With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -> 3.1 MiB). While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): -* Jest 27 will ship with a new test runner (`jest-circus`) and the Node.js environment by default. `jest-jasmine2` and `jest-environment-jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. -* Jest 28 will remove `jest-jasmine2` and `jest-environment-jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. +- Jest 27 will ship with a new test runner (`jest-circus`) and the Node.js environment by default. `jest-jasmine2` and `jest-environment-jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. +- Jest 28 will remove `jest-jasmine2` and `jest-environment-jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new defaults now, and your project does not require a DOM environment, you can upgrade to Jest 26 and add the following configuration options: @@ -36,13 +36,24 @@ Upon upgrading to these major releases, Jest will guide you through the necessar ``` Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for [V8 coverage](/blog/2020/01/21/jest-25#v8-code-coverage) and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. + ## New implementation of fake timers -## Native ESM support + +Since 2017 we've been wanting to swap out Jest's implementation of fake timer with the more feature-complete implementation of Lolex - with Jest 26 this is finally happening! It took so long Lolex has even been renamed in the meantime to `@sinonjs/fake-timers`. It has taken so long since we wanted to make sure the implementation was solid and was usable for all the use cases Jest already supported. We're now confident it is stable enough for everybody to use. + +The new implementation comes with some extra features, such as mocking `Date`, `queueMicrotask` and more, see their [readme](https://github.com/sinonjs/fake-timers/blob/master/README.md) for more details. We're calling the APIs through the Jest APIs you already know, so keep calling `jest.runAllTimers()` etc. like you've been doing. The docs as always are available [here](https://jestjs.io/docs/en/timer-mocks) on our website. + +While we are confident this implementation is ready for prime time, we don't want to force people to rewrite their tests if they depend on Jest's current implementation to work, so for Jest 26 this new implementation will remain _opt-in_. Activate it by calling `jest.useFakeTimers('modern')` or by passing `modern` as the option in your config if you currently have `fake` there. + +We will continue to support the legacy implementation going forward, but we will swap the default over to the "modern" timers in Jest 27. At that time you can opt-in to the legacy implementation by specifying `jest.useFakeTimers('legacy')`. If you know _now_ that you want to keep using the legacy implementation, you can specify that today and not have to change anything when Jest 27 comes around. + +Huge thanks to [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! + ## New way to consume Jest - `@jest/globals` Jest has used the widely known `describe`, `it`, `test` and `expect` globals throughout its lifetime - it's a widely used pattern, it's very easy to get started quickly and we all like the ease globals offers us when writing code. That said, we've heard (loud and clear) that many people don't like globals and that they'd like to import the functions in their tests instead. -With Jest 26*, this is now a possibility through the use of a new package called `@jest/globals`. So now you can do `import { expect, jest, test } from '@jest/globals';` in your tests to your heart's content! +With Jest 26\*, this is now a possibility through the use of a new package called `@jest/globals`. So now you can do `import { expect, jest, test } from '@jest/globals';` in your tests to your heart's content! A couple of quick caveats: @@ -50,26 +61,21 @@ A couple of quick caveats: 1. There's currently no clean way to add custom matchers to the TypeScript definitions. Help appreciated fixing that. 1. If you do `const {jest} = require('@jest/globals')` - i.e. don't use transpiled (or native) `import` syntax, you will get declaration errors as we still inject `jest` into the module scope of every file. The `noGlobals` mode will alleviate this issue -*) This was released in 25.5, but we didn't blog about it! -As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modules-support) we have begun exploring native support for ECMAScript Modules. This work started shipping in Jest 25.3, and has received bug fixes and features in every release since. We're still some distance away from it stabilizing, but any and all help testing it would be highly appreciated! For an overview of the current state you can check out [this issue](https://github.com/facebook/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/facebook/jest/labels/ES%20Modules). -Since 2017 we've been wanting to swap out Jest's implementation of fake timer with the more feature-complete implementation of Lolex - with Jest 26 this is finally happening! It took so long Lolex has even been renamed in the meantime to `@sinonjs/fake-timers`. It has taken so long since we wanted to make sure the implementation was solid and was usable for all the use cases Jest already supported. We're now confident it is stable enough for everybody to use. - -The new implementation comes with some extra features, such as mocking `Date`, `queueMicrotask` and more, see their [readme](https://github.com/sinonjs/fake-timers/blob/master/README.md) for more details. We're calling the APIs through the Jest APIs you already know, so keep calling `jest.runAllTimers()` etc. like you've been doing. The docs as always are available [here](https://jestjs.io/docs/en/timer-mocks) on our website. +\*) This was released in 25.5, but we didn't blog about it! -While we are confident this implementation is ready for prime time, we don't want to force people to rewrite their tests if they depend on Jest's current implementation to work, so for Jest 26 this new implementation will remain _opt-in_. Activate it by calling `jest.useFakeTimers('modern')` or by passing `modern` as the option in your config if you currently have `fake` there. +## Native ESM support -We will continue to support the legacy implementation going forward, but we will swap the default over to the "modern" timers in Jest 27. At that time you can opt-in to the legacy implementation by specifying `jest.useFakeTimers('legacy')`. If you know _now_ that you want to keep using the legacy implementation, you can specify that today and not have to change anything when Jest 27 comes around. +As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modules-support) we have begun exploring native support for ECMAScript Modules. This work started shipping in Jest 25.3, and has received bug fixes and features in every release since. We're still some distance away from it stabilizing, but any and all help testing it would be highly appreciated! For an overview of the current state you can check out [this issue](https://github.com/facebook/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/facebook/jest/labels/ES%20Modules). -Huge thanks to [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! ## Other Breaking Changes in Jest 26 -* Dropped support for Node 8 ([#9423](https://github.com/facebook/jest/pull/9423)) -* `[jest-environment-jsdom]` Upgrade `jsdom` to v16 ([#9606](https://github.com/facebook/jest/pull/9606)) -* `[jest-runtime]` Remove long-deprecated `require.requireActual` and `require.requireMock` methods ([#9854](https://github.com/facebook/jest/pull/9854)) -* `[jest-haste-map]` Removed `providesModuleNodeModules` ([#8535](https://github.com/facebook/jest/pull/8535)) -* `[jest-circus]` Fail tests if a test takes a done callback and have return values ([#9129](https://github.com/facebook/jest/pull/9129)) -* `[jest-circus]` Throw a proper error if a test / hooks is defined asynchronously ([#8096](https://github.com/facebook/jest/pull/8096)) -* ***TODO*** +- Dropped support for Node 8 ([#9423](https://github.com/facebook/jest/pull/9423)) +- `[jest-environment-jsdom]` Upgrade `jsdom` to v16 ([#9606](https://github.com/facebook/jest/pull/9606)) +- `[jest-runtime]` Remove long-deprecated `require.requireActual` and `require.requireMock` methods ([#9854](https://github.com/facebook/jest/pull/9854)) +- `[jest-haste-map]` Removed `providesModuleNodeModules` ([#8535](https://github.com/facebook/jest/pull/8535)) +- `[jest-circus]` Fail tests if a test takes a done callback and have return values ([#9129](https://github.com/facebook/jest/pull/9129)) +- `[jest-circus]` Throw a proper error if a test / hooks is defined asynchronously ([#8096](https://github.com/facebook/jest/pull/8096)) +- **_TODO_** ## Stay Safe From 5f9a0468e626964134392e8e85f347e9ebf79a0b Mon Sep 17 00:00:00 2001 From: cpojer Date: Tue, 5 May 2020 18:25:06 +0100 Subject: [PATCH 17/18] Updates --- website/blog/2020-05-06-jest-26.md | 38 +++++++++++++----------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index d7d928a9efd7..18a3fa136e4b 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -7,7 +7,7 @@ authorFBID: 100000023028168 # Jest 26: Tick Tock -When we started rebuilding Jest five years ago our goal was to provide a batteries-included zero-configuration test runner that is approachable for beginners, extensible for almost all testing use cases and scalable to large projects. One of the most important releases was [Jest 15](https://jestjs.io/blog/2016/09/01/jest-15) which tied all the bits and pieces together and provided great defaults that allowed people to install and run Jest often without any setup. However, this approach has a big downside as Jest installs a lot of dependencies into your projects that you may not need. +When we started rebuilding Jest five years ago our goal was to provide a batteries-included zero-configuration test runner that is approachable for beginners, extensible for almost all testing use cases and scalable to large projects. One of the instrumental releases was [Jest 15](https://jestjs.io/blog/2016/09/01/jest-15) which tied everything together and provided good defaults that allowed people to run Jest often without any setup. However, this approach has a big downside as Jest installs a lot of dependencies into your projects that you may not need. We are now beginning to address this shortcoming and are working on reducing Jest’s install size while keeping it approachable and extensible. We have made the following breaking changes in Jest 26: @@ -19,9 +19,9 @@ We are now beginning to address this shortcoming and are working on reducing Jes With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -> 3.1 MiB). -While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by about 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): +While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by up to 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a [“Tick-Tock" release process](https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model): -- Jest 27 will ship with a new test runner (`jest-circus`) and the Node.js environment by default. `jest-jasmine2` and `jest-environment-jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. +- Jest 27 will ship with a new test runner "`jest-circus`" and the Node.js environment by default. `jest-jasmine2` and `jest-environment-jsdom` will still be bundled so users can keep using them by changing one-line each in the configuration. - Jest 28 will remove `jest-jasmine2` and `jest-environment-jsdom` from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them. Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new defaults now, and your project does not require a DOM environment, you can upgrade to Jest 26 and add the following configuration options: @@ -37,35 +37,30 @@ Upon upgrading to these major releases, Jest will guide you through the necessar Jest will continue to ship with `babel-jest` enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for [V8 coverage](/blog/2020/01/21/jest-25#v8-code-coverage) and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove `babel-jest` as a default but we will keep maintaining it. -## New implementation of fake timers +## New fake timers -Since 2017 we've been wanting to swap out Jest's implementation of fake timer with the more feature-complete implementation of Lolex - with Jest 26 this is finally happening! It took so long Lolex has even been renamed in the meantime to `@sinonjs/fake-timers`. It has taken so long since we wanted to make sure the implementation was solid and was usable for all the use cases Jest already supported. We're now confident it is stable enough for everybody to use. +With Jest 26 we are shipping a new implementation of fake timers based on `@sinonjs/fake-timers`. We've wanted to do this for years and are happy this has finally progressed far enough to support all of Jest's existing fake timer use cases. -The new implementation comes with some extra features, such as mocking `Date`, `queueMicrotask` and more, see their [readme](https://github.com/sinonjs/fake-timers/blob/master/README.md) for more details. We're calling the APIs through the Jest APIs you already know, so keep calling `jest.runAllTimers()` etc. like you've been doing. The docs as always are available [here](https://jestjs.io/docs/en/timer-mocks) on our website. +The new implementation comes with extra features such as mocking `Date`, `queueMicrotask` and more, see [this README](https://github.com/sinonjs/fake-timers/blob/master/README.md). It works transparently using the existing timer APIs like `jest.runAllTimers()` – check out the documentation [on our website](https://jestjs.io/docs/en/timer-mocks). -While we are confident this implementation is ready for prime time, we don't want to force people to rewrite their tests if they depend on Jest's current implementation to work, so for Jest 26 this new implementation will remain _opt-in_. Activate it by calling `jest.useFakeTimers('modern')` or by passing `modern` as the option in your config if you currently have `fake` there. +We are confident this implementation is ready for prime time, however we don't want to force people to rewrite their tests if they depend on subtle differences between the old and new implementation. In Jest 26, this new implementation will remain *opt-in* and can be activated by calling `jest.useFakeTimers('modern')` or by passing `modern` to the `timers` option in your config if you opted all tests into fake timers previously. -We will continue to support the legacy implementation going forward, but we will swap the default over to the "modern" timers in Jest 27. At that time you can opt-in to the legacy implementation by specifying `jest.useFakeTimers('legacy')`. If you know _now_ that you want to keep using the legacy implementation, you can specify that today and not have to change anything when Jest 27 comes around. +In Jest 27 we will swap the default to the new "modern" implementation but we will keep supporting and maintaining the legacy implementation which can be used by calling `jest.useFakeTimers('legacy')`. If you are unsure whether you'll be able to upgrade all your tests by the time Jest 27 rolls out, you can add this to your tests now to keep the old behavior. -Huge thanks to [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! +We'd like to thank [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! *Exciting*. -## New way to consume Jest - `@jest/globals` +## A new way to consume Jest - `@jest/globals` -Jest has used the widely known `describe`, `it`, `test` and `expect` globals throughout its lifetime - it's a widely used pattern, it's very easy to get started quickly and we all like the ease globals offers us when writing code. That said, we've heard (loud and clear) that many people don't like globals and that they'd like to import the functions in their tests instead. +Jest has relied on globals popularized by the Jasmine testing framework and others such as `describe`, `it`, `test` and `expect`. While this is a widely used patterns, many people have expressed their preference for importing testing related functions instead. To support this use case, we added a new package `@jest/globals` that can be used to import testing functions: `import {expect, jest, test} from '@jest/globals';`. -With Jest 26\*, this is now a possibility through the use of a new package called `@jest/globals`. So now you can do `import { expect, jest, test } from '@jest/globals';` in your tests to your heart's content! - -A couple of quick caveats: - -1. The globals still exist in the environment - we will introduce a `noGlobals` mode in the future for those who wants no globals whatsoever -1. There's currently no clean way to add custom matchers to the TypeScript definitions. Help appreciated fixing that. -1. If you do `const {jest} = require('@jest/globals')` - i.e. don't use transpiled (or native) `import` syntax, you will get declaration errors as we still inject `jest` into the module scope of every file. The `noGlobals` mode will alleviate this issue - -\*) This was released in 25.5, but we didn't blog about it! +Caveats: +* Currently the globals still exist in the environment but we will introduce a mode to disable globals in the future. Similarly, you cannot use `const jest = require('@jest/globals')` as you'll get declaration orders because the `jest` variable is still a global for now. +* There is currently no way to add custom matchers to the TypeScript definitions when using globals like this. +* While this allows running tests without globals, it does not allow running tests without Jest's test runner at this time. ## Native ESM support -As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modules-support) we have begun exploring native support for ECMAScript Modules. This work started shipping in Jest 25.3, and has received bug fixes and features in every release since. We're still some distance away from it stabilizing, but any and all help testing it would be highly appreciated! For an overview of the current state you can check out [this issue](https://github.com/facebook/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/facebook/jest/labels/ES%20Modules). +As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modules-support) we have been working on native support for ECMAScript Modules. It is not stable yet but it is ready to be tested. We'd love to hear your feedback and bug reports! For an overview of the current state you can check out [this issue](https://github.com/facebook/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/facebook/jest/labels/ES%20Modules). ## Other Breaking Changes in Jest 26 @@ -75,7 +70,6 @@ As mentioned in the [Jest 25 blog post](/blog/2020/01/21/jest-25#ecmascript-modu - `[jest-haste-map]` Removed `providesModuleNodeModules` ([#8535](https://github.com/facebook/jest/pull/8535)) - `[jest-circus]` Fail tests if a test takes a done callback and have return values ([#9129](https://github.com/facebook/jest/pull/9129)) - `[jest-circus]` Throw a proper error if a test / hooks is defined asynchronously ([#8096](https://github.com/facebook/jest/pull/8096)) -- **_TODO_** ## Stay Safe From 4be59fef6eb94e617f9184edc8afb1d75a1ef602 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 5 May 2020 19:33:04 +0200 Subject: [PATCH 18/18] prettier --- website/blog/2020-05-06-jest-26.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/website/blog/2020-05-06-jest-26.md b/website/blog/2020-05-06-jest-26.md index 18a3fa136e4b..6a692c2ad202 100644 --- a/website/blog/2020-05-06-jest-26.md +++ b/website/blog/2020-05-06-jest-26.md @@ -43,20 +43,21 @@ With Jest 26 we are shipping a new implementation of fake timers based on `@sino The new implementation comes with extra features such as mocking `Date`, `queueMicrotask` and more, see [this README](https://github.com/sinonjs/fake-timers/blob/master/README.md). It works transparently using the existing timer APIs like `jest.runAllTimers()` – check out the documentation [on our website](https://jestjs.io/docs/en/timer-mocks). -We are confident this implementation is ready for prime time, however we don't want to force people to rewrite their tests if they depend on subtle differences between the old and new implementation. In Jest 26, this new implementation will remain *opt-in* and can be activated by calling `jest.useFakeTimers('modern')` or by passing `modern` to the `timers` option in your config if you opted all tests into fake timers previously. +We are confident this implementation is ready for prime time, however we don't want to force people to rewrite their tests if they depend on subtle differences between the old and new implementation. In Jest 26, this new implementation will remain _opt-in_ and can be activated by calling `jest.useFakeTimers('modern')` or by passing `modern` to the `timers` option in your config if you opted all tests into fake timers previously. In Jest 27 we will swap the default to the new "modern" implementation but we will keep supporting and maintaining the legacy implementation which can be used by calling `jest.useFakeTimers('legacy')`. If you are unsure whether you'll be able to upgrade all your tests by the time Jest 27 rolls out, you can add this to your tests now to keep the old behavior. -We'd like to thank [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! *Exciting*. +We'd like to thank [Carl-Erik Kopseng](https://github.com/fatso83), [Benjamin Gruenbaum](https://github.com/benjamingr) and other maintainers of `@sinonjs/fake-timers` for their help and patience when working with us to make this happen! _Exciting_. ## A new way to consume Jest - `@jest/globals` -Jest has relied on globals popularized by the Jasmine testing framework and others such as `describe`, `it`, `test` and `expect`. While this is a widely used patterns, many people have expressed their preference for importing testing related functions instead. To support this use case, we added a new package `@jest/globals` that can be used to import testing functions: `import {expect, jest, test} from '@jest/globals';`. +Jest has relied on globals popularized by the Jasmine testing framework and others such as `describe`, `it`, `test` and `expect`. While this is a widely used pattern, many people have expressed their preference for importing testing related functions instead. To support this use case, we added a new package `@jest/globals` that can be used to import testing functions: `import {expect, jest, test} from '@jest/globals';`. Caveats: -* Currently the globals still exist in the environment but we will introduce a mode to disable globals in the future. Similarly, you cannot use `const jest = require('@jest/globals')` as you'll get declaration orders because the `jest` variable is still a global for now. -* There is currently no way to add custom matchers to the TypeScript definitions when using globals like this. -* While this allows running tests without globals, it does not allow running tests without Jest's test runner at this time. + +- Currently the globals still exist in the environment but we will introduce a mode to disable globals in the future. Similarly, you cannot use `const jest = require('@jest/globals')` as you'll get declaration orders because the `jest` variable is still a global for now. +- There is currently no way to add custom matchers to the TypeScript definitions when using globals like this. +- While this allows running tests without globals, it does not allow running tests without Jest's test runner at this time. ## Native ESM support