From 49bacb9620b87c476bd5ba1b30e26ca2c4f42a70 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Tue, 15 Aug 2023 14:00:44 +0100 Subject: [PATCH] chore: update jest repo organisation in urls (#14413) --- .eslintrc.cjs | 2 +- .github/ISSUE_TEMPLATE.md | 2 +- .github/ISSUE_TEMPLATE/bug.yml | 2 +- CONTRIBUTING.md | 4 +-- README.md | 20 +++++++------- constraints.pro | 2 +- docs/CodeTransformation.md | 4 +-- docs/Configuration.md | 26 +++++++++---------- docs/ECMAScriptModules.md | 4 +-- docs/ExpectAPI.md | 2 +- docs/GlobalAPI.md | 10 +++---- docs/JestObjectAPI.md | 2 +- docs/JestPlatform.md | 10 +++---- docs/ManualMocks.md | 2 +- docs/MoreResources.md | 2 +- docs/Puppeteer.md | 2 +- docs/SnapshotTesting.md | 12 ++++----- docs/Troubleshooting.md | 4 +-- docs/TutorialAsync.md | 2 +- docs/TutorialReact.md | 4 +-- docs/TutorialReactNative.md | 2 +- docs/TutorialjQuery.md | 2 +- docs/UpgradingToJest29.md | 2 +- docs/WatchPlugins.md | 2 +- e2e/__tests__/console.test.ts | 2 +- e2e/__tests__/dependencyClash.test.ts | 2 +- e2e/__tests__/toMatchInlineSnapshot.test.ts | 2 +- e2e/snapshot/__tests__/snapshot.test.js | 2 +- .../testSequencer.js | 2 +- packages/babel-jest/README.md | 2 +- packages/babel-jest/package.json | 2 +- packages/babel-plugin-jest-hoist/README.md | 2 +- packages/babel-plugin-jest-hoist/package.json | 2 +- packages/babel-preset-jest/README.md | 2 +- packages/babel-preset-jest/package.json | 2 +- packages/diff-sequences/package.json | 2 +- packages/expect-utils/package.json | 2 +- packages/expect-utils/src/utils.ts | 2 +- packages/expect/package.json | 2 +- .../expect/src/__tests__/toEqual-dom.test.ts | 2 +- packages/jest-changed-files/package.json | 2 +- packages/jest-circus/README.md | 2 +- packages/jest-circus/package.json | 2 +- packages/jest-cli/package.json | 4 +-- packages/jest-config/package.json | 2 +- packages/jest-console/package.json | 2 +- packages/jest-console/src/BufferedConsole.ts | 2 +- packages/jest-console/src/CustomConsole.ts | 2 +- packages/jest-core/package.json | 4 +-- .../jest-core/src/__tests__/watch.test.js | 2 +- packages/jest-core/src/collectHandles.ts | 2 +- packages/jest-core/src/testSchedulerHelper.ts | 2 +- .../package.json | 2 +- packages/jest-diff/package.json | 2 +- packages/jest-docblock/package.json | 2 +- packages/jest-each/README.md | 2 +- packages/jest-each/package.json | 2 +- packages/jest-environment-jsdom/package.json | 2 +- packages/jest-environment-node/package.json | 2 +- packages/jest-environment/package.json | 2 +- packages/jest-expect/package.json | 2 +- packages/jest-fake-timers/package.json | 2 +- .../jest-fake-timers/src/legacyFakeTimers.ts | 2 +- packages/jest-get-type/package.json | 2 +- packages/jest-globals/package.json | 2 +- packages/jest-haste-map/package.json | 2 +- packages/jest-haste-map/src/crawlers/node.ts | 2 +- packages/jest-haste-map/src/index.ts | 4 +-- .../lib/__tests__/dependencyExtractor.test.js | 2 +- packages/jest-jasmine2/package.json | 2 +- packages/jest-leak-detector/package.json | 2 +- packages/jest-matcher-utils/README.md | 2 +- packages/jest-matcher-utils/package.json | 2 +- packages/jest-message-util/package.json | 2 +- packages/jest-message-util/src/index.ts | 2 +- packages/jest-mock/package.json | 2 +- packages/jest-phabricator/package.json | 2 +- packages/jest-regex-util/package.json | 2 +- packages/jest-repl/package.json | 2 +- packages/jest-reporters/package.json | 4 +-- .../jest-reporters/src/CoverageReporter.ts | 2 +- .../src/GitHubActionsReporter.ts | 2 +- .../jest-reporters/src/VerboseReporter.ts | 2 +- .../jest-resolve-dependencies/package.json | 2 +- packages/jest-resolve/package.json | 2 +- packages/jest-runner/package.json | 2 +- packages/jest-runtime/package.json | 2 +- packages/jest-schemas/package.json | 2 +- packages/jest-snapshot/package.json | 2 +- packages/jest-source-map/package.json | 2 +- packages/jest-test-result/package.json | 2 +- packages/jest-test-sequencer/package.json | 2 +- packages/jest-transform/package.json | 2 +- .../jest-transform/src/ScriptTransformer.ts | 2 +- packages/jest-types/package.json | 2 +- packages/jest-util/package.json | 2 +- packages/jest-util/src/createProcessObject.ts | 2 +- packages/jest-validate/package.json | 2 +- packages/jest-watcher/package.json | 4 +-- packages/jest-worker/README.md | 2 +- packages/jest-worker/package.json | 2 +- packages/jest-worker/src/types.ts | 2 +- .../workers/__tests__/WorkerEdgeCases.test.ts | 2 +- packages/jest/package.json | 2 +- packages/pretty-format/package.json | 2 +- website/README.md | 2 +- ...-11-javascript-unit-testing-performance.md | 2 +- website/blog/2016-04-12-jest-11.md | 6 ++--- website/blog/2016-06-22-jest-13.md | 2 +- website/blog/2016-07-27-jest-14.md | 12 ++++----- website/blog/2016-09-01-jest-15.md | 10 +++---- website/blog/2016-10-03-jest-16.md | 2 +- website/blog/2016-12-15-2016-in-jest.md | 12 ++++----- ...2017-01-30-a-great-developer-experience.md | 2 +- ...e-watch-mode-test-platform-improvements.md | 20 +++++++------- ...delightful-testing-multi-project-runner.md | 4 +-- website/blog/2017-12-18-jest-22.md | 8 +++--- ...jest-23-blazing-fast-delightful-testing.md | 4 +-- ...refreshing-polished-typescript-friendly.md | 26 +++++++++---------- website/blog/2020-01-21-jest-25.md | 16 ++++++------ website/blog/2020-05-05-jest-26.md | 22 ++++++++-------- .../blog/2021-03-09-jest-website-upgrade.md | 2 +- website/blog/2021-05-25-jest-27.md | 22 ++++++++-------- website/blog/2022-04-25-jest-28.md | 4 +-- website/blog/2022-08-25-jest-29.md | 2 +- website/docusaurus.config.js | 8 +++--- website/src/pages/help.js | 2 +- website/src/pages/index.js | 4 +-- website/src/pages/versions.js | 4 +-- website/static/_redirects | 2 +- website/users.json | 2 +- .../version-25.x/Configuration.md | 24 ++++++++--------- .../version-25.x/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-25.x/ExpectAPI.md | 2 +- .../version-25.x/JestObjectAPI.md | 2 +- .../version-25.x/JestPlatform.md | 10 +++---- .../version-25.x/ManualMocks.md | 2 +- .../version-25.x/MockFunctionAPI.md | 2 +- .../version-25.x/MoreResources.md | 2 +- .../versioned_docs/version-25.x/Puppeteer.md | 2 +- .../version-25.x/SnapshotTesting.md | 12 ++++----- .../versioned_docs/version-25.x/TimerMocks.md | 2 +- .../version-25.x/Troubleshooting.md | 4 +-- .../version-25.x/TutorialAsync.md | 2 +- .../version-25.x/TutorialReact.md | 4 +-- .../version-25.x/TutorialReactNative.md | 2 +- .../version-25.x/TutorialjQuery.md | 2 +- .../version-25.x/WatchPlugins.md | 2 +- .../version-26.x/Configuration.md | 24 ++++++++--------- .../version-26.x/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-26.x/ExpectAPI.md | 2 +- .../versioned_docs/version-26.x/GlobalAPI.md | 2 +- .../version-26.x/JestObjectAPI.md | 2 +- .../version-26.x/JestPlatform.md | 10 +++---- .../version-26.x/ManualMocks.md | 2 +- .../version-26.x/MockFunctionAPI.md | 2 +- .../version-26.x/MoreResources.md | 2 +- .../versioned_docs/version-26.x/Puppeteer.md | 2 +- .../version-26.x/SnapshotTesting.md | 12 ++++----- .../versioned_docs/version-26.x/TimerMocks.md | 2 +- .../version-26.x/Troubleshooting.md | 4 +-- .../version-26.x/TutorialAsync.md | 2 +- .../version-26.x/TutorialReact.md | 4 +-- .../version-26.x/TutorialReactNative.md | 2 +- .../version-26.x/TutorialjQuery.md | 2 +- .../version-26.x/WatchPlugins.md | 2 +- .../version-27.x/CodeTransformation.md | 2 +- .../version-27.x/Configuration.md | 24 ++++++++--------- .../version-27.x/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-27.x/ExpectAPI.md | 2 +- .../versioned_docs/version-27.x/GlobalAPI.md | 2 +- .../version-27.x/JestObjectAPI.md | 2 +- .../version-27.x/JestPlatform.md | 10 +++---- .../version-27.x/ManualMocks.md | 2 +- .../version-27.x/MockFunctionAPI.md | 2 +- .../version-27.x/MoreResources.md | 2 +- .../versioned_docs/version-27.x/Puppeteer.md | 2 +- .../version-27.x/SnapshotTesting.md | 12 ++++----- .../versioned_docs/version-27.x/TimerMocks.md | 2 +- .../version-27.x/Troubleshooting.md | 4 +-- .../version-27.x/TutorialAsync.md | 2 +- .../version-27.x/TutorialReact.md | 4 +-- .../version-27.x/TutorialReactNative.md | 2 +- .../version-27.x/TutorialjQuery.md | 2 +- .../version-27.x/WatchPlugins.md | 2 +- .../version-28.x/CodeTransformation.md | 4 +-- .../version-28.x/Configuration.md | 22 ++++++++-------- .../version-28.x/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-28.x/ExpectAPI.md | 2 +- .../versioned_docs/version-28.x/GlobalAPI.md | 8 +++--- .../version-28.x/JestObjectAPI.md | 2 +- .../version-28.x/JestPlatform.md | 10 +++---- .../version-28.x/ManualMocks.md | 2 +- .../version-28.x/MoreResources.md | 2 +- .../versioned_docs/version-28.x/Puppeteer.md | 2 +- .../version-28.x/SnapshotTesting.md | 12 ++++----- .../version-28.x/Troubleshooting.md | 4 +-- .../version-28.x/TutorialAsync.md | 2 +- .../version-28.x/TutorialReact.md | 4 +-- .../version-28.x/TutorialReactNative.md | 2 +- .../version-28.x/TutorialjQuery.md | 2 +- .../version-28.x/UpgradingToJest28.md | 4 +-- .../version-28.x/WatchPlugins.md | 2 +- .../version-29.0/CodeTransformation.md | 4 +-- .../version-29.0/Configuration.md | 26 +++++++++---------- .../version-29.0/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.0/ExpectAPI.md | 2 +- .../versioned_docs/version-29.0/GlobalAPI.md | 10 +++---- .../version-29.0/JestObjectAPI.md | 2 +- .../version-29.0/JestPlatform.md | 10 +++---- .../version-29.0/ManualMocks.md | 2 +- .../version-29.0/MoreResources.md | 2 +- .../versioned_docs/version-29.0/Puppeteer.md | 2 +- .../version-29.0/SnapshotTesting.md | 12 ++++----- .../version-29.0/Troubleshooting.md | 4 +-- .../version-29.0/TutorialAsync.md | 2 +- .../version-29.0/TutorialReact.md | 4 +-- .../version-29.0/TutorialReactNative.md | 2 +- .../version-29.0/TutorialjQuery.md | 2 +- .../version-29.0/UpgradingToJest29.md | 2 +- .../version-29.0/WatchPlugins.md | 2 +- .../version-29.1/CodeTransformation.md | 4 +-- .../version-29.1/Configuration.md | 26 +++++++++---------- .../version-29.1/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.1/ExpectAPI.md | 2 +- .../versioned_docs/version-29.1/GlobalAPI.md | 10 +++---- .../version-29.1/JestObjectAPI.md | 2 +- .../version-29.1/JestPlatform.md | 10 +++---- .../version-29.1/ManualMocks.md | 2 +- .../version-29.1/MoreResources.md | 2 +- .../versioned_docs/version-29.1/Puppeteer.md | 2 +- .../version-29.1/SnapshotTesting.md | 12 ++++----- .../version-29.1/Troubleshooting.md | 4 +-- .../version-29.1/TutorialAsync.md | 2 +- .../version-29.1/TutorialReact.md | 4 +-- .../version-29.1/TutorialReactNative.md | 2 +- .../version-29.1/TutorialjQuery.md | 2 +- .../version-29.1/UpgradingToJest29.md | 2 +- .../version-29.1/WatchPlugins.md | 2 +- .../version-29.2/CodeTransformation.md | 4 +-- .../version-29.2/Configuration.md | 24 ++++++++--------- .../version-29.2/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.2/ExpectAPI.md | 2 +- .../versioned_docs/version-29.2/GlobalAPI.md | 10 +++---- .../version-29.2/JestObjectAPI.md | 2 +- .../version-29.2/JestPlatform.md | 10 +++---- .../version-29.2/ManualMocks.md | 2 +- .../version-29.2/MoreResources.md | 2 +- .../versioned_docs/version-29.2/Puppeteer.md | 2 +- .../version-29.2/SnapshotTesting.md | 12 ++++----- .../version-29.2/Troubleshooting.md | 4 +-- .../version-29.2/TutorialAsync.md | 2 +- .../version-29.2/TutorialReact.md | 4 +-- .../version-29.2/TutorialReactNative.md | 2 +- .../version-29.2/TutorialjQuery.md | 2 +- .../version-29.2/UpgradingToJest29.md | 2 +- .../version-29.2/WatchPlugins.md | 2 +- .../version-29.3/CodeTransformation.md | 4 +-- .../version-29.3/Configuration.md | 26 +++++++++---------- .../version-29.3/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.3/ExpectAPI.md | 2 +- .../versioned_docs/version-29.3/GlobalAPI.md | 10 +++---- .../version-29.3/JestObjectAPI.md | 2 +- .../version-29.3/JestPlatform.md | 10 +++---- .../version-29.3/ManualMocks.md | 2 +- .../version-29.3/MoreResources.md | 2 +- .../versioned_docs/version-29.3/Puppeteer.md | 2 +- .../version-29.3/SnapshotTesting.md | 12 ++++----- .../version-29.3/Troubleshooting.md | 4 +-- .../version-29.3/TutorialAsync.md | 2 +- .../version-29.3/TutorialReact.md | 4 +-- .../version-29.3/TutorialReactNative.md | 2 +- .../version-29.3/TutorialjQuery.md | 2 +- .../version-29.3/UpgradingToJest29.md | 2 +- .../version-29.3/WatchPlugins.md | 2 +- .../version-29.4/CodeTransformation.md | 4 +-- .../version-29.4/Configuration.md | 26 +++++++++---------- .../version-29.4/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.4/ExpectAPI.md | 2 +- .../versioned_docs/version-29.4/GlobalAPI.md | 10 +++---- .../version-29.4/JestObjectAPI.md | 2 +- .../version-29.4/JestPlatform.md | 10 +++---- .../version-29.4/ManualMocks.md | 2 +- .../version-29.4/MoreResources.md | 2 +- .../versioned_docs/version-29.4/Puppeteer.md | 2 +- .../version-29.4/SnapshotTesting.md | 12 ++++----- .../version-29.4/Troubleshooting.md | 4 +-- .../version-29.4/TutorialAsync.md | 2 +- .../version-29.4/TutorialReact.md | 4 +-- .../version-29.4/TutorialReactNative.md | 2 +- .../version-29.4/TutorialjQuery.md | 2 +- .../version-29.4/UpgradingToJest29.md | 2 +- .../version-29.4/WatchPlugins.md | 2 +- .../version-29.5/CodeTransformation.md | 4 +-- .../version-29.5/Configuration.md | 26 +++++++++---------- .../version-29.5/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.5/ExpectAPI.md | 2 +- .../versioned_docs/version-29.5/GlobalAPI.md | 10 +++---- .../version-29.5/JestObjectAPI.md | 2 +- .../version-29.5/JestPlatform.md | 10 +++---- .../version-29.5/ManualMocks.md | 2 +- .../version-29.5/MoreResources.md | 2 +- .../versioned_docs/version-29.5/Puppeteer.md | 2 +- .../version-29.5/SnapshotTesting.md | 12 ++++----- .../version-29.5/Troubleshooting.md | 4 +-- .../version-29.5/TutorialAsync.md | 2 +- .../version-29.5/TutorialReact.md | 4 +-- .../version-29.5/TutorialReactNative.md | 2 +- .../version-29.5/TutorialjQuery.md | 2 +- .../version-29.5/UpgradingToJest29.md | 2 +- .../version-29.5/WatchPlugins.md | 2 +- .../version-29.6/CodeTransformation.md | 4 +-- .../version-29.6/Configuration.md | 26 +++++++++---------- .../version-29.6/ECMAScriptModules.md | 4 +-- .../versioned_docs/version-29.6/ExpectAPI.md | 2 +- .../versioned_docs/version-29.6/GlobalAPI.md | 10 +++---- .../version-29.6/JestObjectAPI.md | 2 +- .../version-29.6/JestPlatform.md | 10 +++---- .../version-29.6/ManualMocks.md | 2 +- .../version-29.6/MoreResources.md | 2 +- .../versioned_docs/version-29.6/Puppeteer.md | 2 +- .../version-29.6/SnapshotTesting.md | 12 ++++----- .../version-29.6/Troubleshooting.md | 4 +-- .../version-29.6/TutorialAsync.md | 2 +- .../version-29.6/TutorialReact.md | 4 +-- .../version-29.6/TutorialReactNative.md | 2 +- .../version-29.6/TutorialjQuery.md | 2 +- .../version-29.6/UpgradingToJest29.md | 2 +- .../version-29.6/WatchPlugins.md | 2 +- 329 files changed, 746 insertions(+), 746 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d2f6e0f5d60a..089863ba5f5e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -128,7 +128,7 @@ module.exports = { rules: { '@typescript-eslint/ban-types': [ 'error', - // TODO: remove these overrides: https://github.com/facebook/jest/issues/10177 + // TODO: remove these overrides: https://github.com/jestjs/jest/issues/10177 {types: {Function: false, object: false, '{}': false}}, ], 'local/ban-types-eventually': [ diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 8b0483e22ec9..62a266204106 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ -## 👉 [Please follow one of these issue templates](https://github.com/facebook/jest/issues/new/choose) 👈 +## 👉 [Please follow one of these issue templates](https://github.com/jestjs/jest/issues/new/choose) 👈 diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 60128a50d325..a208081cbdb7 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -41,7 +41,7 @@ body: label: Version description: | The version of Jest you are using. - Is it the [latest](https://github.com/facebook/jest/releases)? Test and see if the bug has already been fixed. + Is it the [latest](https://github.com/jestjs/jest/releases)? Test and see if the bug has already been fixed. placeholder: ex. 27.0.6 validations: required: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68902505e39f..2e018e5fc568 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Jest is one of Facebook's open-source projects that is both under very active development and is also being used to ship code to everybody on [Facebook.com](https://www.facebook.com). We're still working out the kinks to make contributing to this project as easy and transparent as possible, but we're not quite there yet. Hopefully, this document makes the process for contributing clear and answers some questions that you may have. -If you want an already configured online IDE to contribute to Jest, you can use [Gitpod](https://gitpod.io/#https://github.com/facebook/jest)! +If you want an already configured online IDE to contribute to Jest, you can use [Gitpod](https://gitpod.io/#https://github.com/jestjs/jest)! ## [Code of Conduct](https://code.facebook.com/codeofconduct) @@ -131,7 +131,7 @@ Ran all test suites. ## Checking Constraints -We use [Yarn Constraints](https://yarnpkg.com/features/constraints) to enforce various rules across the repository. They are declared inside the [`constraints.pro` file](https://github.com/facebook/jest/blob/main/constraints.pro) and their purposes are documented with comments. +We use [Yarn Constraints](https://yarnpkg.com/features/constraints) to enforce various rules across the repository. They are declared inside the [`constraints.pro` file](https://github.com/jestjs/jest/blob/main/constraints.pro) and their purposes are documented with comments. Constraints can be checked with `yarn constraints`, and fixed with `yarn constraints --fix`. Generally speaking: diff --git a/README.md b/README.md index b7e005413c95..ba462358a145 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ npm version - + Jest is released under the MIT license. @@ -10,11 +10,11 @@

- GitHub CI Status + GitHub CI Status Coverage Status

- Gitpod ready-to-code + Gitpod ready-to-code

@@ -229,13 +229,13 @@ Learn more about using [Jest on the official site!](https://jestjs.io) ## Badge -Show the world you're using _Jest_ `→` [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) [![jest tested](https://img.shields.io/badge/Jest-tested-eee.svg?logo=jest&labelColor=99424f)](https://github.com/facebook/jest) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest) +Show the world you're using _Jest_ `→` [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/jestjs/jest) [![jest tested](https://img.shields.io/badge/Jest-tested-eee.svg?logo=jest&labelColor=99424f)](https://github.com/jestjs/jest) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/jestjs/jest) ```md -[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg?logo=jest)](https://github.com/facebook/jest) -[![jest tested](https://img.shields.io/badge/Jest-tested-eee.svg?logo=jest&labelColor=99424f)](https://github.com/facebook/jest) -[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest) +[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg?logo=jest)](https://github.com/jestjs/jest) +[![jest tested](https://img.shields.io/badge/Jest-tested-eee.svg?logo=jest&labelColor=99424f)](https://github.com/jestjs/jest) +[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/jestjs/jest) ``` ## Contributing @@ -250,15 +250,15 @@ Facebook has adopted a Code of Conduct that we expect project participants to ad Read our [contributing guide](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Jest. -### [Good First Issues](https://github.com/facebook/jest/labels/good%20first%20issue) +### [Good First Issues](https://github.com/jestjs/jest/labels/good%20first%20issue) -To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first issues](https://github.com/facebook/jest/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started. +To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first issues](https://github.com/jestjs/jest/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started. ## Credits This project exists thanks to all the people who [contribute](CONTRIBUTING.md). - + ### [Backers](https://opencollective.com/jest#backer) diff --git a/constraints.pro b/constraints.pro index b9179863ccfb..e0f1abbe277e 100644 --- a/constraints.pro +++ b/constraints.pro @@ -43,7 +43,7 @@ gen_enforced_field(WorkspaceCwd, 'license', null) :- % Enforces the repository field for all public workspaces while removing it from private workspaces gen_enforced_field(WorkspaceCwd, 'repository.type', 'git') :- \+ workspace_field(WorkspaceCwd, 'private', true). -gen_enforced_field(WorkspaceCwd, 'repository.url', 'https://github.com/facebook/jest.git') :- +gen_enforced_field(WorkspaceCwd, 'repository.url', 'https://github.com/jestjs/jest.git') :- \+ workspace_field(WorkspaceCwd, 'private', true). gen_enforced_field(WorkspaceCwd, 'repository.directory', WorkspaceCwd) :- \+ workspace_field(WorkspaceCwd, 'private', true). diff --git a/docs/CodeTransformation.md b/docs/CodeTransformation.md index d2a568fcb024..14d96a16f649 100644 --- a/docs/CodeTransformation.md +++ b/docs/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/docs/Configuration.md b/docs/Configuration.md index 0fe862f4bb3d..4e23e314b103 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -1401,7 +1401,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1583,7 +1583,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1837,7 +1837,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1860,9 +1860,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2149,7 +2149,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2189,7 +2189,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2231,7 +2231,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2446,7 +2446,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2464,7 +2464,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/docs/ECMAScriptModules.md b/docs/ECMAScriptModules.md index 1aa9a39b0c68..feaed6bdb961 100644 --- a/docs/ECMAScriptModules.md +++ b/docs/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -48,7 +48,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/docs/ExpectAPI.md b/docs/ExpectAPI.md index d140e0dd4340..46b2c361585e 100644 --- a/docs/ExpectAPI.md +++ b/docs/ExpectAPI.md @@ -1591,7 +1591,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/docs/GlobalAPI.md b/docs/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/docs/GlobalAPI.md +++ b/docs/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index d3811b628b86..130e6d7768a2 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -1071,7 +1071,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/docs/JestPlatform.md b/docs/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/docs/JestPlatform.md +++ b/docs/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/docs/ManualMocks.md b/docs/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/docs/ManualMocks.md +++ b/docs/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/docs/MoreResources.md b/docs/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/docs/MoreResources.md +++ b/docs/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/docs/Puppeteer.md b/docs/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/docs/Puppeteer.md +++ b/docs/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/docs/SnapshotTesting.md b/docs/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/docs/SnapshotTesting.md +++ b/docs/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/docs/TutorialAsync.md b/docs/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/docs/TutorialAsync.md +++ b/docs/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/docs/TutorialReact.md b/docs/TutorialReact.md index 13165b1b4e95..fd6f7620acce 100644 --- a/docs/TutorialReact.md +++ b/docs/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). ### Custom transformers diff --git a/docs/TutorialReactNative.md b/docs/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/docs/TutorialReactNative.md +++ b/docs/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/docs/TutorialjQuery.md b/docs/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/docs/TutorialjQuery.md +++ b/docs/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/docs/UpgradingToJest29.md b/docs/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/docs/UpgradingToJest29.md +++ b/docs/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/docs/WatchPlugins.md b/docs/WatchPlugins.md index acb66e0a8673..57ddeaec07e4 100644 --- a/docs/WatchPlugins.md +++ b/docs/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/e2e/__tests__/console.test.ts b/e2e/__tests__/console.test.ts index 163f612ed3a1..051f30e2e86d 100644 --- a/e2e/__tests__/console.test.ts +++ b/e2e/__tests__/console.test.ts @@ -82,7 +82,7 @@ test('respects noStackTrace in config', () => { expect(summary).toMatchSnapshot(); }); -// issue: https://github.com/facebook/jest/issues/5223 +// issue: https://github.com/jestjs/jest/issues/5223 test('the jsdom console is the same as the test console', () => { const {stderr, stdout, exitCode} = runJest('console-jsdom'); const {summary, rest} = extractSummary(stderr); diff --git a/e2e/__tests__/dependencyClash.test.ts b/e2e/__tests__/dependencyClash.test.ts index 311c89453d4d..4783514805f0 100644 --- a/e2e/__tests__/dependencyClash.test.ts +++ b/e2e/__tests__/dependencyClash.test.ts @@ -25,7 +25,7 @@ beforeEach(() => { // `invariant` package from npm and `invariant.js` that provides `invariant` // module we can still require the right invariant. This is pretty specific // use case and in the future we should probably delete this test. -// see: https://github.com/facebook/jest/pull/6687 +// see: https://github.com/jestjs/jest/pull/6687 test('does not require project modules from inside node_modules', () => { writeFiles(tempDir, { '__tests__/test.js': ` diff --git a/e2e/__tests__/toMatchInlineSnapshot.test.ts b/e2e/__tests__/toMatchInlineSnapshot.test.ts index 483fe0ab904a..446609348377 100644 --- a/e2e/__tests__/toMatchInlineSnapshot.test.ts +++ b/e2e/__tests__/toMatchInlineSnapshot.test.ts @@ -249,7 +249,7 @@ test('writes snapshots with non-literals in expect(...)', () => { expect(fileAfter).toMatchSnapshot(); }); -// issue: https://github.com/facebook/jest/issues/6702 +// issue: https://github.com/jestjs/jest/issues/6702 test('handles mocking native modules prettier relies on', () => { const filename = 'mockFail.test.js'; const test = ` diff --git a/e2e/snapshot/__tests__/snapshot.test.js b/e2e/snapshot/__tests__/snapshot.test.js index 3947650b5b36..428adb059667 100644 --- a/e2e/snapshot/__tests__/snapshot.test.js +++ b/e2e/snapshot/__tests__/snapshot.test.js @@ -34,7 +34,7 @@ describe('snapshot', () => { ); }); - // Issue reported here: https://github.com/facebook/jest/issues/2969 + // Issue reported here: https://github.com/jestjs/jest/issues/2969 it('works with \\r\\n', () => { expect('
\r\n
').toMatchSnapshot(); }); diff --git a/e2e/worker-restart-before-send/testSequencer.js b/e2e/worker-restart-before-send/testSequencer.js index e5a470ed49fe..a5e9b5d43ed5 100644 --- a/e2e/worker-restart-before-send/testSequencer.js +++ b/e2e/worker-restart-before-send/testSequencer.js @@ -13,7 +13,7 @@ const Sequencer = require('@jest/test-sequencer').default; class CustomSequencer extends Sequencer { sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } diff --git a/packages/babel-jest/README.md b/packages/babel-jest/README.md index 95050196b2a0..8716cc13c818 100644 --- a/packages/babel-jest/README.md +++ b/packages/babel-jest/README.md @@ -1,6 +1,6 @@ # babel-jest -[Babel](https://github.com/babel/babel) [jest](https://github.com/facebook/jest) plugin +[Babel](https://github.com/babel/babel) [jest](https://github.com/jestjs/jest) plugin ## Usage diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index 71d8b7e14381..27bda5279438 100644 --- a/packages/babel-jest/package.json +++ b/packages/babel-jest/package.json @@ -4,7 +4,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/babel-jest" }, "license": "MIT", diff --git a/packages/babel-plugin-jest-hoist/README.md b/packages/babel-plugin-jest-hoist/README.md index 1a90bbe8b165..7c1421bb27f1 100644 --- a/packages/babel-plugin-jest-hoist/README.md +++ b/packages/babel-plugin-jest-hoist/README.md @@ -1,6 +1,6 @@ # babel-plugin-jest-hoist -Babel plugin to hoist `jest.disableAutomock`, `jest.enableAutomock`, `jest.unmock`, `jest.mock`, calls above `import` statements. This plugin is automatically included when using [babel-jest](https://github.com/facebook/jest/tree/main/packages/babel-jest). +Babel plugin to hoist `jest.disableAutomock`, `jest.enableAutomock`, `jest.unmock`, `jest.mock`, calls above `import` statements. This plugin is automatically included when using [babel-jest](https://github.com/jestjs/jest/tree/main/packages/babel-jest). ## Installation diff --git a/packages/babel-plugin-jest-hoist/package.json b/packages/babel-plugin-jest-hoist/package.json index 3698c80ff7a9..d56194756057 100644 --- a/packages/babel-plugin-jest-hoist/package.json +++ b/packages/babel-plugin-jest-hoist/package.json @@ -3,7 +3,7 @@ "version": "29.5.0", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/babel-plugin-jest-hoist" }, "engines": { diff --git a/packages/babel-preset-jest/README.md b/packages/babel-preset-jest/README.md index 4457c086cece..745e1b031072 100644 --- a/packages/babel-preset-jest/README.md +++ b/packages/babel-preset-jest/README.md @@ -1,6 +1,6 @@ # babel-preset-jest -> Babel preset for all Jest plugins. This preset is automatically included when using [babel-jest](https://github.com/facebook/jest/tree/main/packages/babel-jest). +> Babel preset for all Jest plugins. This preset is automatically included when using [babel-jest](https://github.com/jestjs/jest/tree/main/packages/babel-jest). ## Install diff --git a/packages/babel-preset-jest/package.json b/packages/babel-preset-jest/package.json index 735fd90b35f1..4d664eca8cd4 100644 --- a/packages/babel-preset-jest/package.json +++ b/packages/babel-preset-jest/package.json @@ -3,7 +3,7 @@ "version": "29.5.0", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/babel-preset-jest" }, "license": "MIT", diff --git a/packages/diff-sequences/package.json b/packages/diff-sequences/package.json index ee91b067bbdc..4ba131b9da33 100644 --- a/packages/diff-sequences/package.json +++ b/packages/diff-sequences/package.json @@ -3,7 +3,7 @@ "version": "29.4.3", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/diff-sequences" }, "license": "MIT", diff --git a/packages/expect-utils/package.json b/packages/expect-utils/package.json index 2487565b4252..7aa8251bb7ee 100644 --- a/packages/expect-utils/package.json +++ b/packages/expect-utils/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/expect-utils" }, "license": "MIT", diff --git a/packages/expect-utils/src/utils.ts b/packages/expect-utils/src/utils.ts index 62c3085a56fa..cb4ab7fda33f 100644 --- a/packages/expect-utils/src/utils.ts +++ b/packages/expect-utils/src/utils.ts @@ -377,7 +377,7 @@ export const typeEquality = (a: any, b: any): boolean | undefined => { // Since Jest globals are different from Node globals, // constructors are different even between arrays when comparing properties of mock objects. // Both of them should be able to compare correctly when they are array-to-array. - // https://github.com/facebook/jest/issues/2549 + // https://github.com/jestjs/jest/issues/2549 (Array.isArray(a) && Array.isArray(b)) ) { return undefined; diff --git a/packages/expect/package.json b/packages/expect/package.json index 08b75c77559d..8882f53f5002 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/expect" }, "license": "MIT", diff --git a/packages/expect/src/__tests__/toEqual-dom.test.ts b/packages/expect/src/__tests__/toEqual-dom.test.ts index 2dc5c8b3110b..09270754f54d 100644 --- a/packages/expect/src/__tests__/toEqual-dom.test.ts +++ b/packages/expect/src/__tests__/toEqual-dom.test.ts @@ -15,7 +15,7 @@ import {expect} from '@jest/globals'; describe('toEqual', () => { describe('duck type', () => { - // https://github.com/facebook/jest/issues/7786 + // https://github.com/jestjs/jest/issues/7786 const createElement = (name: string, ...childNodes: Array) => ({ childNodes, diff --git a/packages/jest-changed-files/package.json b/packages/jest-changed-files/package.json index 866a23a3992e..a0a5c5cd1e25 100644 --- a/packages/jest-changed-files/package.json +++ b/packages/jest-changed-files/package.json @@ -3,7 +3,7 @@ "version": "29.5.0", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-changed-files" }, "license": "MIT", diff --git a/packages/jest-circus/README.md b/packages/jest-circus/README.md index 75a2f771d23d..6c5c68363388 100644 --- a/packages/jest-circus/README.md +++ b/packages/jest-circus/README.md @@ -1,4 +1,4 @@ -[type-definitions]: https://github.com/facebook/jest/blob/main/packages/jest-types/src/Circus.ts +[type-definitions]: https://github.com/jestjs/jest/blob/main/packages/jest-types/src/Circus.ts

diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index 89305b99ad15..9e9253fe952a 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-circus" }, "license": "MIT", diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index bb0532334f73..684aa0f981df 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -50,11 +50,11 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-cli" }, "bugs": { - "url": "https://github.com/facebook/jest/issues" + "url": "https://github.com/jestjs/jest/issues" }, "homepage": "https://jestjs.io/", "license": "MIT", diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 6630d1a2b47a..2ac8f06dfabd 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-config" }, "license": "MIT", diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 5155e9157a81..bd69334c0be5 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-console" }, "license": "MIT", diff --git a/packages/jest-console/src/BufferedConsole.ts b/packages/jest-console/src/BufferedConsole.ts index b91117bf36e6..526d51c38fdf 100644 --- a/packages/jest-console/src/BufferedConsole.ts +++ b/packages/jest-console/src/BufferedConsole.ts @@ -79,7 +79,7 @@ export default class BufferedConsole extends Console { if (!(error instanceof AssertionError)) { throw error; } - // https://github.com/facebook/jest/pull/13422#issuecomment-1273396392 + // https://github.com/jestjs/jest/pull/13422#issuecomment-1273396392 this._log('assert', error.toString().replace(/:\n\n.*\n/gs, '')); } } diff --git a/packages/jest-console/src/CustomConsole.ts b/packages/jest-console/src/CustomConsole.ts index 04b23c023553..451971604e55 100644 --- a/packages/jest-console/src/CustomConsole.ts +++ b/packages/jest-console/src/CustomConsole.ts @@ -56,7 +56,7 @@ export default class CustomConsole extends Console { if (!(error instanceof AssertionError)) { throw error; } - // https://github.com/facebook/jest/pull/13422#issuecomment-1273396392 + // https://github.com/jestjs/jest/pull/13422#issuecomment-1273396392 this._logError('assert', error.toString().replace(/:\n\n.*\n/gs, '')); } } diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 93eac1eff68b..7c6989e582dc 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -61,11 +61,11 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-core" }, "bugs": { - "url": "https://github.com/facebook/jest/issues" + "url": "https://github.com/jestjs/jest/issues" }, "homepage": "https://jestjs.io/", "license": "MIT", diff --git a/packages/jest-core/src/__tests__/watch.test.js b/packages/jest-core/src/__tests__/watch.test.js index 7f412e1561a3..8bd334bd91a4 100644 --- a/packages/jest-core/src/__tests__/watch.test.js +++ b/packages/jest-core/src/__tests__/watch.test.js @@ -446,7 +446,7 @@ describe('Watch mode flows', () => { ); // The jury's still out on 'a', 'c', 'f', 'o', 'w' and '?'… - // See https://github.com/facebook/jest/issues/6693 + // See https://github.com/jestjs/jest/issues/6693 it.each` key | plugin ${'t'} | ${'TestNamePattern'} diff --git a/packages/jest-core/src/collectHandles.ts b/packages/jest-core/src/collectHandles.ts index a88d58ffdbdd..3a9172fd18f1 100644 --- a/packages/jest-core/src/collectHandles.ts +++ b/packages/jest-core/src/collectHandles.ts @@ -145,7 +145,7 @@ export default function collectHandles(): HandleCollectionResult { if (activeHandles.size > 0) { // For some special objects such as `TLSWRAP`. - // Ref: https://github.com/facebook/jest/issues/11665 + // Ref: https://github.com/jestjs/jest/issues/11665 runGC(); await asyncSleep(0); diff --git a/packages/jest-core/src/testSchedulerHelper.ts b/packages/jest-core/src/testSchedulerHelper.ts index 6582415ac5d5..79c7a056ee95 100644 --- a/packages/jest-core/src/testSchedulerHelper.ts +++ b/packages/jest-core/src/testSchedulerHelper.ts @@ -41,7 +41,7 @@ export function shouldRunInBand( * quickly we also run in band to reduce the overhead of spawning workers. * Finally, the user can provide the runInBand argument in the CLI to * force running in band, which sets maxWorkers to 1 here: - * https://github.com/facebook/jest/blob/d106643a8ee0ffa9c2f11c6bb2d12094e99135aa/packages/jest-config/src/getMaxWorkers.ts#L27-L28 + * https://github.com/jestjs/jest/blob/d106643a8ee0ffa9c2f11c6bb2d12094e99135aa/packages/jest-config/src/getMaxWorkers.ts#L27-L28 */ const areFastTests = timings.every(timing => timing < SLOW_TEST_TIME); const oneWorkerOrLess = maxWorkers <= 1; diff --git a/packages/jest-create-cache-key-function/package.json b/packages/jest-create-cache-key-function/package.json index ec1e7a883304..4446994ec170 100644 --- a/packages/jest-create-cache-key-function/package.json +++ b/packages/jest-create-cache-key-function/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-create-cache-key-function" }, "dependencies": { diff --git a/packages/jest-diff/package.json b/packages/jest-diff/package.json index c79474c9eb32..6488ec8e3df3 100644 --- a/packages/jest-diff/package.json +++ b/packages/jest-diff/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-diff" }, "license": "MIT", diff --git a/packages/jest-docblock/package.json b/packages/jest-docblock/package.json index 421c0c5d361f..df23f9d258ef 100644 --- a/packages/jest-docblock/package.json +++ b/packages/jest-docblock/package.json @@ -3,7 +3,7 @@ "version": "29.4.3", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-docblock" }, "license": "MIT", diff --git a/packages/jest-each/README.md b/packages/jest-each/README.md index da3b2adb9e4a..3b4384387ca4 100644 --- a/packages/jest-each/README.md +++ b/packages/jest-each/README.md @@ -5,7 +5,7 @@
-[![version](https://img.shields.io/npm/v/jest-each.svg?style=flat-square)](https://www.npmjs.com/package/jest-each) [![downloads](https://img.shields.io/npm/dm/jest-each.svg?style=flat-square)](http://npm-stat.com/charts.html?package=jest-each&from=2017-03-21) [![MIT License](https://img.shields.io/npm/l/jest-each.svg?style=flat-square)](https://github.com/facebook/jest/blob/main/LICENSE) +[![version](https://img.shields.io/npm/v/jest-each.svg?style=flat-square)](https://www.npmjs.com/package/jest-each) [![downloads](https://img.shields.io/npm/dm/jest-each.svg?style=flat-square)](http://npm-stat.com/charts.html?package=jest-each&from=2017-03-21) [![MIT License](https://img.shields.io/npm/l/jest-each.svg?style=flat-square)](https://github.com/jestjs/jest/blob/main/LICENSE) A parameterised testing library for [Jest](https://jestjs.io/) inspired by [mocha-each](https://github.com/ryym/mocha-each). diff --git a/packages/jest-each/package.json b/packages/jest-each/package.json index 0e3480c0a304..1005558319de 100644 --- a/packages/jest-each/package.json +++ b/packages/jest-each/package.json @@ -13,7 +13,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-each" }, "keywords": [ diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index c6beacb6fe96..2060256623af 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-environment-jsdom" }, "license": "MIT", diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index 90678c040ee5..304ecf582529 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-environment-node" }, "license": "MIT", diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index 7c87e934f280..a8c104f47811 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-environment" }, "license": "MIT", diff --git a/packages/jest-expect/package.json b/packages/jest-expect/package.json index 237e497cd777..578f6ca43c98 100644 --- a/packages/jest-expect/package.json +++ b/packages/jest-expect/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-expect" }, "license": "MIT", diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index 4a37d2511827..eea6721c0826 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-fake-timers" }, "license": "MIT", diff --git a/packages/jest-fake-timers/src/legacyFakeTimers.ts b/packages/jest-fake-timers/src/legacyFakeTimers.ts index f04e12083b8a..e4e05fec7618 100644 --- a/packages/jest-fake-timers/src/legacyFakeTimers.ts +++ b/packages/jest-fake-timers/src/legacyFakeTimers.ts @@ -244,7 +244,7 @@ export default class FakeTimers { runOnlyPendingTimers(): void { // We need to hold the current shape of `this._timers` because existing // timers can add new ones to the map and hence would run more than necessary. - // See https://github.com/facebook/jest/pull/4608 for details + // See https://github.com/jestjs/jest/pull/4608 for details const timerEntries = Array.from(this._timers.entries()); this._checkFakeTimers(); this._immediates.forEach(this._runImmediate, this); diff --git a/packages/jest-get-type/package.json b/packages/jest-get-type/package.json index 97222a4016bc..5463bac7458d 100644 --- a/packages/jest-get-type/package.json +++ b/packages/jest-get-type/package.json @@ -4,7 +4,7 @@ "version": "29.4.3", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-get-type" }, "engines": { diff --git a/packages/jest-globals/package.json b/packages/jest-globals/package.json index 815c3add9ed8..39797cfa07a3 100644 --- a/packages/jest-globals/package.json +++ b/packages/jest-globals/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-globals" }, "engines": { diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index 1a4319a1e719..b6964dae1346 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-haste-map" }, "license": "MIT", diff --git a/packages/jest-haste-map/src/crawlers/node.ts b/packages/jest-haste-map/src/crawlers/node.ts index 014fef8a1a25..8555eeb7b415 100644 --- a/packages/jest-haste-map/src/crawlers/node.ts +++ b/packages/jest-haste-map/src/crawlers/node.ts @@ -162,7 +162,7 @@ function findNative( let stdout = ''; if (child.stdout === null) { throw new Error( - 'stdout is null - this should never happen. Please open up an issue at https://github.com/facebook/jest', + 'stdout is null - this should never happen. Please open up an issue at https://github.com/jestjs/jest', ); } child.stdout.setEncoding('utf-8'); diff --git a/packages/jest-haste-map/src/index.ts b/packages/jest-haste-map/src/index.ts index bc65149445bf..5012d6ef1af5 100644 --- a/packages/jest-haste-map/src/index.ts +++ b/packages/jest-haste-map/src/index.ts @@ -46,9 +46,9 @@ import type { WorkerMetadata, } from './types'; import {FSEventsWatcher} from './watchers/FSEventsWatcher'; -// @ts-expect-error: not converted to TypeScript - it's a fork: https://github.com/facebook/jest/pull/10919 +// @ts-expect-error: not converted to TypeScript - it's a fork: https://github.com/jestjs/jest/pull/10919 import NodeWatcher from './watchers/NodeWatcher'; -// @ts-expect-error: not converted to TypeScript - it's a fork: https://github.com/facebook/jest/pull/5387 +// @ts-expect-error: not converted to TypeScript - it's a fork: https://github.com/jestjs/jest/pull/5387 import WatchmanWatcher from './watchers/WatchmanWatcher'; import {getSha1, worker} from './worker'; // TypeScript doesn't like us importing from outside `rootDir`, but it doesn't diff --git a/packages/jest-haste-map/src/lib/__tests__/dependencyExtractor.test.js b/packages/jest-haste-map/src/lib/__tests__/dependencyExtractor.test.js index 2fe56e4ce67d..d07cb7b5187b 100644 --- a/packages/jest-haste-map/src/lib/__tests__/dependencyExtractor.test.js +++ b/packages/jest-haste-map/src/lib/__tests__/dependencyExtractor.test.js @@ -70,7 +70,7 @@ describe('dependencyExtractor', () => { ); }); - // https://github.com/facebook/jest/issues/8547 + // https://github.com/jestjs/jest/issues/8547 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only it('should extract dependencies from side-effect only `import` statements', () => { const code = ` diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index d95864779f9c..0953e9a2679a 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-jasmine2" }, "license": "MIT", diff --git a/packages/jest-leak-detector/package.json b/packages/jest-leak-detector/package.json index e39523ba29b1..5cea240be6ef 100644 --- a/packages/jest-leak-detector/package.json +++ b/packages/jest-leak-detector/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-leak-detector" }, "license": "MIT", diff --git a/packages/jest-matcher-utils/README.md b/packages/jest-matcher-utils/README.md index d3e9d13bf849..17e19c2bca92 100644 --- a/packages/jest-matcher-utils/README.md +++ b/packages/jest-matcher-utils/README.md @@ -9,7 +9,7 @@ To add this package as a dependency of a project, run either of the following co - `npm install jest-matcher-utils` - `yarn add jest-matcher-utils` -## Exports ([src/index.ts](https://github.com/facebook/jest/blob/HEAD/packages/jest-matcher-utils/src/index.ts)) +## Exports ([src/index.ts](https://github.com/jestjs/jest/blob/HEAD/packages/jest-matcher-utils/src/index.ts)) ### Functions diff --git a/packages/jest-matcher-utils/package.json b/packages/jest-matcher-utils/package.json index 1f948f2f9e01..0dcf8a3bd94e 100644 --- a/packages/jest-matcher-utils/package.json +++ b/packages/jest-matcher-utils/package.json @@ -4,7 +4,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-matcher-utils" }, "engines": { diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index 408630ed3e31..8a713cfd61ba 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-message-util" }, "engines": { diff --git a/packages/jest-message-util/src/index.ts b/packages/jest-message-util/src/index.ts index 37078cbc842b..9455f9b4fb0f 100644 --- a/packages/jest-message-util/src/index.ts +++ b/packages/jest-message-util/src/index.ts @@ -355,7 +355,7 @@ export const formatStackTrace = ( let fileContent; try { // TODO: check & read HasteFS instead of reading the filesystem: - // see: https://github.com/facebook/jest/pull/5405#discussion_r164281696 + // see: https://github.com/jestjs/jest/pull/5405#discussion_r164281696 fileContent = fs.readFileSync(filename, 'utf8'); renderedCallsite = getRenderedCallsite(fileContent, line, column); } catch { diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index f8442e28c493..d161044f93d5 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-mock" }, "license": "MIT", diff --git a/packages/jest-phabricator/package.json b/packages/jest-phabricator/package.json index 439813195aff..02ff6570875b 100644 --- a/packages/jest-phabricator/package.json +++ b/packages/jest-phabricator/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-phabricator" }, "types": "./build/index.d.ts", diff --git a/packages/jest-regex-util/package.json b/packages/jest-regex-util/package.json index e35fe605cb9d..a947a4eb09eb 100644 --- a/packages/jest-regex-util/package.json +++ b/packages/jest-regex-util/package.json @@ -3,7 +3,7 @@ "version": "29.4.3", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-regex-util" }, "devDependencies": { diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index 703d4c717224..bcdb54472c2a 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-repl" }, "license": "MIT", diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index c38dad8debed..db659285d78d 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -67,11 +67,11 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-reporters" }, "bugs": { - "url": "https://github.com/facebook/jest/issues" + "url": "https://github.com/jestjs/jest/issues" }, "homepage": "https://jestjs.io/", "license": "MIT", diff --git a/packages/jest-reporters/src/CoverageReporter.ts b/packages/jest-reporters/src/CoverageReporter.ts index 84aefc822803..953c4ed4be51 100644 --- a/packages/jest-reporters/src/CoverageReporter.ts +++ b/packages/jest-reporters/src/CoverageReporter.ts @@ -274,7 +274,7 @@ export default class CoverageReporter extends BaseReporter { Array<[string, string]> >((agg, thresholdGroup) => { // Preserve trailing slash, but not required if root dir - // See https://github.com/facebook/jest/issues/12703 + // See https://github.com/jestjs/jest/issues/12703 const resolvedThresholdGroup = path.resolve(thresholdGroup); const suffix = (thresholdGroup.endsWith(path.sep) || diff --git a/packages/jest-reporters/src/GitHubActionsReporter.ts b/packages/jest-reporters/src/GitHubActionsReporter.ts index df9640214742..b5024068cdf2 100644 --- a/packages/jest-reporters/src/GitHubActionsReporter.ts +++ b/packages/jest-reporters/src/GitHubActionsReporter.ts @@ -161,7 +161,7 @@ export default class GitHubActionsReporter extends BaseReporter { return true; } else { throw new Error( - `Sum(${computedTotal}) of passed (${passedTestSuites}) and failed (${failedTestSuites}) test suites is greater than the total number of test suites (${totalTestSuites}). Please report the bug at https://github.com/facebook/jest/issues`, + `Sum(${computedTotal}) of passed (${passedTestSuites}) and failed (${failedTestSuites}) test suites is greater than the total number of test suites (${totalTestSuites}). Please report the bug at https://github.com/jestjs/jest/issues`, ); } } diff --git a/packages/jest-reporters/src/VerboseReporter.ts b/packages/jest-reporters/src/VerboseReporter.ts index 03dfb6ff3f95..46ae16d6a4b1 100644 --- a/packages/jest-reporters/src/VerboseReporter.ts +++ b/packages/jest-reporters/src/VerboseReporter.ts @@ -30,7 +30,7 @@ export default class VerboseReporter extends DefaultReporter { } // Verbose mode is for debugging. Buffering of output is undesirable. - // See https://github.com/facebook/jest/issues/8208 + // See https://github.com/jestjs/jest/issues/8208 protected override __wrapStdio( stream: NodeJS.WritableStream | NodeJS.WriteStream, ): void { diff --git a/packages/jest-resolve-dependencies/package.json b/packages/jest-resolve-dependencies/package.json index ca7977d75d0e..1fa24663d173 100644 --- a/packages/jest-resolve-dependencies/package.json +++ b/packages/jest-resolve-dependencies/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-resolve-dependencies" }, "license": "MIT", diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index e52ed10a7866..c3e450021874 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-resolve" }, "license": "MIT", diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 263a69c2b6d9..1c519464bd50 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-runner" }, "license": "MIT", diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index 11ea2d47a71d..48daf4f01b4c 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-runtime" }, "license": "MIT", diff --git a/packages/jest-schemas/package.json b/packages/jest-schemas/package.json index 11fe033bda2d..75fcf613723c 100644 --- a/packages/jest-schemas/package.json +++ b/packages/jest-schemas/package.json @@ -3,7 +3,7 @@ "version": "29.6.0", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-schemas" }, "license": "MIT", diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index 385a2bcb24c0..dfd8b9c6bb2f 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-snapshot" }, "license": "MIT", diff --git a/packages/jest-source-map/package.json b/packages/jest-source-map/package.json index 91dd9629a19e..3f046969c8e0 100644 --- a/packages/jest-source-map/package.json +++ b/packages/jest-source-map/package.json @@ -3,7 +3,7 @@ "version": "29.6.0", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-source-map" }, "license": "MIT", diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index 2fdb26147a46..a442b5538daf 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-test-result" }, "license": "MIT", diff --git a/packages/jest-test-sequencer/package.json b/packages/jest-test-sequencer/package.json index 60aacc26dba5..5b222e3eb514 100644 --- a/packages/jest-test-sequencer/package.json +++ b/packages/jest-test-sequencer/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-test-sequencer" }, "license": "MIT", diff --git a/packages/jest-transform/package.json b/packages/jest-transform/package.json index 98d514debf6b..3888bf8acfee 100644 --- a/packages/jest-transform/package.json +++ b/packages/jest-transform/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-transform" }, "license": "MIT", diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index a73015488b07..6728407dfcb9 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -411,7 +411,7 @@ class ScriptTransformer { if (transformed.map == null || transformed.map === '') { try { //Could be a potential freeze here. - //See: https://github.com/facebook/jest/pull/5177#discussion_r158883570 + //See: https://github.com/jestjs/jest/pull/5177#discussion_r158883570 const inlineSourceMap = sourcemapFromSource(transformed.code); if (inlineSourceMap) { transformed.map = inlineSourceMap.toObject() as FixedRawSourceMap; diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index c2d647296408..bb8bdf35ddbc 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -3,7 +3,7 @@ "version": "29.6.1", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-types" }, "engines": { diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index ff043991ddd8..e166a053e16f 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-util" }, "license": "MIT", diff --git a/packages/jest-util/src/createProcessObject.ts b/packages/jest-util/src/createProcessObject.ts index 1cb8b26d7614..252b121275be 100644 --- a/packages/jest-util/src/createProcessObject.ts +++ b/packages/jest-util/src/createProcessObject.ts @@ -92,7 +92,7 @@ export default function createProcessObject(): NodeJS.Process { } catch (e: any) { // Make sure it's actually set instead of potentially ignoring errors if (newProcess[Symbol.toStringTag] !== 'process') { - e.message = `Unable to set toStringTag on process. Please open up an issue at https://github.com/facebook/jest\n\n${e.message}`; + e.message = `Unable to set toStringTag on process. Please open up an issue at https://github.com/jestjs/jest\n\n${e.message}`; throw e; } diff --git a/packages/jest-validate/package.json b/packages/jest-validate/package.json index b3a178c1f7b5..cdc9667feb73 100644 --- a/packages/jest-validate/package.json +++ b/packages/jest-validate/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-validate" }, "license": "MIT", diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index 500b635be96a..fc98d2cc20ae 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -23,11 +23,11 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-watcher" }, "bugs": { - "url": "https://github.com/facebook/jest/issues" + "url": "https://github.com/jestjs/jest/issues" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" diff --git a/packages/jest-worker/README.md b/packages/jest-worker/README.md index bf14f9fe7e5d..f9e1131c95e7 100644 --- a/packages/jest-worker/README.md +++ b/packages/jest-worker/README.md @@ -77,7 +77,7 @@ Allow customizing all options passed to `child_process.fork`. By default, some v #### `idleMemoryLimit: number` (optional) -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a task the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. If no limit is set this process does not occur. The limit can be specified in 2 ways: diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index 4a87d8a9a37b..034700d8c76c 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest-worker" }, "license": "MIT", diff --git a/packages/jest-worker/src/types.ts b/packages/jest-worker/src/types.ts index dbd1f2b430a1..9d0e45a172ab 100644 --- a/packages/jest-worker/src/types.ts +++ b/packages/jest-worker/src/types.ts @@ -178,7 +178,7 @@ export type WorkerOptions = { idleMemoryLimit?: number; /** * This mainly exists so the path can be changed during testing. - * https://github.com/facebook/jest/issues/9543 + * https://github.com/jestjs/jest/issues/9543 */ childWorkerPath?: string; /** diff --git a/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.ts b/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.ts index 50ea9daf40af..3b283cc9c925 100644 --- a/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.ts +++ b/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.ts @@ -413,7 +413,7 @@ describe.each([ }); }); - // Regression test for https://github.com/facebook/jest/issues/13183 + // Regression test for https://github.com/jestjs/jest/issues/13183 test('onEnd callback is called', async () => { let onEndPromiseResolve: () => void; let onEndPromiseReject: (err: Error) => void; diff --git a/packages/jest/package.json b/packages/jest/package.json index 5997ffbe0fbc..49b28053d5b3 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -36,7 +36,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/jest" }, "homepage": "https://jestjs.io/", diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index 7834250963b2..788d1e3b1a71 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -3,7 +3,7 @@ "version": "29.6.2", "repository": { "type": "git", - "url": "https://github.com/facebook/jest.git", + "url": "https://github.com/jestjs/jest.git", "directory": "packages/pretty-format" }, "license": "MIT", diff --git a/website/README.md b/website/README.md index 2508657003cd..008dc10d9bab 100644 --- a/website/README.md +++ b/website/README.md @@ -44,4 +44,4 @@ An older Docusaurus v1 site exist for versions <= 25.x: - Netlify site: https://app.netlify.com/sites/jest-archive - Url: https://archive.jestjs.io -- GitHub branch: https://github.com/facebook/jest/tree/jest-website-v1 +- GitHub branch: https://github.com/jestjs/jest/tree/jest-website-v1 diff --git a/website/blog/2016-03-11-javascript-unit-testing-performance.md b/website/blog/2016-03-11-javascript-unit-testing-performance.md index 706dc9a642c8..1baa53b30c39 100644 --- a/website/blog/2016-03-11-javascript-unit-testing-performance.md +++ b/website/blog/2016-03-11-javascript-unit-testing-performance.md @@ -114,6 +114,6 @@ A lot of the above changes improved the test runtime by 10% or sometimes even 50 More importantly, adding new tests causes total runtime to grow very slowly. Engineers can write and run more tests without feeling the costs. -With Jest's recent 0.9 release and performance improvements from the [node-haste2 integration](https://github.com/facebook/jest/pull/599), the runtime of the [Relay](https://github.com/facebook/relay) framework's test suite went down from 60 seconds to about 25 and the [react-native](https://github.com/facebook/react-native) test suite now finishes in less than ten seconds on a 13” MacBook Pro. +With Jest's recent 0.9 release and performance improvements from the [node-haste2 integration](https://github.com/jestjs/jest/pull/599), the runtime of the [Relay](https://github.com/facebook/relay) framework's test suite went down from 60 seconds to about 25 and the [react-native](https://github.com/facebook/react-native) test suite now finishes in less than ten seconds on a 13” MacBook Pro. We're very happy with the wins we've seen so far, and we're going to keep working on Jest and making it better. If you are curious about contributing to Jest, feel free get in touch on GitHub, [Discord](https://discord.gg/j6FKKQQrW9) or Facebook :) diff --git a/website/blog/2016-04-12-jest-11.md b/website/blog/2016-04-12-jest-11.md index 230e5f32c7ac..8a2be7f94663 100644 --- a/website/blog/2016-04-12-jest-11.md +++ b/website/blog/2016-04-12-jest-11.md @@ -13,7 +13,7 @@ If you are using Jest 0.9 or Jest 0.10 the upgrade should be seamless. All chang #### Babel Integration and Simplified Setup -`babel-jest` was adopted within the newly modularized Jest [repository](https://github.com/facebook/jest/tree/main/packages) and it is now seamlessly integrated into Jest. If you are upgrading from an older version of Jest or are looking to adopt Jest, we recommend reading the [Getting Started guide](/docs/getting-started). +`babel-jest` was adopted within the newly modularized Jest [repository](https://github.com/jestjs/jest/tree/main/packages) and it is now seamlessly integrated into Jest. If you are upgrading from an older version of Jest or are looking to adopt Jest, we recommend reading the [Getting Started guide](/docs/getting-started). @@ -78,7 +78,7 @@ We recently wrote about some [performance improvements](/blog/2016/03/11/javascr #### Jasmine and Test Assertion Improvements -When Jest was open sourced it shipped with Jasmine 1. Jest was designed to work with any test assertion library and optional Jasmine 2 support was added through an [external contribution](https://github.com/facebook/jest/pull/330) at the end of last year. This change delivers better performance and provides a better APIs over the previous version of Jasmine. As such, we have converted all our JavaScript tests at Facebook to Jasmine 2. With Jest 11 we are making Jasmine 2 the new default. Jasmine 1 can be enabled through the [`testRunner`](/docs/api#testrunner-string) configuration option. +When Jest was open sourced it shipped with Jasmine 1. Jest was designed to work with any test assertion library and optional Jasmine 2 support was added through an [external contribution](https://github.com/jestjs/jest/pull/330) at the end of last year. This change delivers better performance and provides a better APIs over the previous version of Jasmine. As such, we have converted all our JavaScript tests at Facebook to Jasmine 2. With Jest 11 we are making Jasmine 2 the new default. Jasmine 1 can be enabled through the [`testRunner`](/docs/api#testrunner-string) configuration option. We have also made many updates around Jasmine. The failure messages for custom matchers provided for Jest's mock functions were improved and will now also work for Jasmine spies. Skipped tests, when using `fit` or `fdescribe,` are now properly reported at the end of a test run. @@ -86,7 +86,7 @@ We have also made many updates around Jasmine. The failure messages for custom m The `jest --watch` command has been rewritten and improved. By default it now only runs tests related to changed files. If you want to run all tests on every change, you can run `jest --watch=all`. The verbose logger output has also been improved and we've added more helpful warnings and error messages. We added a [`testEnvironment`](/docs/api#testenvironment-string) configuration option to customize the test environment. For example, when building a node service, a special `node` environment instead of `jsdom` can be used. Finally, the website and all documentation have been completely rewritten. -All changes from the past few months can be found in the [CHANGELOG](https://github.com/facebook/jest/blob/main/CHANGELOG.md). +All changes from the past few months can be found in the [CHANGELOG](https://github.com/jestjs/jest/blob/main/CHANGELOG.md). ### Contributions And Jest's future diff --git a/website/blog/2016-06-22-jest-13.md b/website/blog/2016-06-22-jest-13.md index 2cf9af2ccdf5..7d2310a7fae6 100644 --- a/website/blog/2016-06-22-jest-13.md +++ b/website/blog/2016-06-22-jest-13.md @@ -11,7 +11,7 @@ The Flow project has evolved a lot within Facebook and has been successfully ado -With the help of [lerna](https://github.com/lerna/lerna), we continued to modularize the Jest project. With just a small [update to the configuration](https://github.com/lerna/lerna#lernajson), Flow and lerna now get along well with each other. Splitting up Jest into packages helped us rethink module boundaries and enabled us to ship useful [packages](https://github.com/facebook/jest/tree/main/packages) standalone: The `jest-runtime` and `jest-repl` cli tools now allow you to run scripts in a sandboxed Jest environment, enabling you to run and debug your app from the command line. This is especially helpful for projects that use Facebook's `@providesModule` module convention. To get started, just install `jest-repl` and run it in the same folder you normally run your tests in! We also published a `jest-changed-files` package that finds changed files in version control for either git or hg, a common thing in developer tools. +With the help of [lerna](https://github.com/lerna/lerna), we continued to modularize the Jest project. With just a small [update to the configuration](https://github.com/lerna/lerna#lernajson), Flow and lerna now get along well with each other. Splitting up Jest into packages helped us rethink module boundaries and enabled us to ship useful [packages](https://github.com/jestjs/jest/tree/main/packages) standalone: The `jest-runtime` and `jest-repl` cli tools now allow you to run scripts in a sandboxed Jest environment, enabling you to run and debug your app from the command line. This is especially helpful for projects that use Facebook's `@providesModule` module convention. To get started, just install `jest-repl` and run it in the same folder you normally run your tests in! We also published a `jest-changed-files` package that finds changed files in version control for either git or hg, a common thing in developer tools. ## New and improved features diff --git a/website/blog/2016-07-27-jest-14.md b/website/blog/2016-07-27-jest-14.md index 77ddd42b622b..b9c66f4fa3ce 100644 --- a/website/blog/2016-07-27-jest-14.md +++ b/website/blog/2016-07-27-jest-14.md @@ -11,7 +11,7 @@ One of the big open questions was how to write React tests efficiently. There ar -Together with the React team we created a new test renderer for React and added snapshot testing to Jest. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a simple [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +Together with the React team we created a new test renderer for React and added snapshot testing to Jest. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a simple [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```javascript import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ test('Link renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`Link renders correctly 1`] = ` @@ -43,7 +43,7 @@ If we change the address the Link component in our example is pointing to, Jest ![snapshot-testing](/img/blog/snapshot.png) -Now you know that you either need to accept the changes with `jest -u`, or fix the component if the changes were unintentional. To try out this functionality, please clone the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modify the Link component and run Jest. We updated the [React Tutorial](/docs/tutorial-react) with a new guide for snapshot testing. +Now you know that you either need to accept the changes with `jest -u`, or fix the component if the changes were unintentional. To try out this functionality, please clone the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modify the Link component and run Jest. We updated the [React Tutorial](/docs/tutorial-react) with a new guide for snapshot testing. This feature was built by [Ben Alpert](https://twitter.com/soprano) and [Cristian Carlesso](https://twitter.com/kentaromiura). @@ -60,12 +60,12 @@ You can start using Jest with react-native by running `yarn add --dev jest-react ``` - [Tutorial and setup guide](/docs/tutorial-react-native#content) -- [Example project](https://github.com/facebook/jest/tree/main/examples/react-native) +- [Example project](https://github.com/jestjs/jest/tree/main/examples/react-native) - [Example pull request for _snowflake_](https://github.com/bartonhammond/snowflake/pull/110), a popular react-native open source library. :::info -The preset currently only implements the minimal set of configuration necessary to get started with React Native testing. We are hoping for community contributions to improve this project. Please try it and file [issues](https://github.com/facebook/jest/issues) or send pull requests! +The preset currently only implements the minimal set of configuration necessary to get started with React Native testing. We are hoping for community contributions to improve this project. Please try it and file [issues](https://github.com/jestjs/jest/issues) or send pull requests! ::: @@ -79,7 +79,7 @@ While this was the solution we wanted for the web, we also found many problems w - **Fast iteration speed:** Engineers want to get results in less than a second rather than waiting for minutes or even hours. If tests don't run quickly like in most end-to-end frameworks, engineers don't run them at all or don't bother writing them in the first place. - **Debugging:** It's easy to step into the code of an integration test in JS instead of trying to recreate the screenshot test scenario and debugging what happened in the visual diff. -Because we believe snapshot testing can be useful beyond Jest we split the feature into a [jest-snapshot](https://github.com/facebook/jest/tree/main/packages/jest-snapshot) package. We are happy to work with the community to make it more generic so it can be integrated with other test runners and share concepts and infrastructure with each other. +Because we believe snapshot testing can be useful beyond Jest we split the feature into a [jest-snapshot](https://github.com/jestjs/jest/tree/main/packages/jest-snapshot) package. We are happy to work with the community to make it more generic so it can be integrated with other test runners and share concepts and infrastructure with each other. Finally, here is a quote of a Facebook engineer describing how snapshot testing changed his unit testing experience: diff --git a/website/blog/2016-09-01-jest-15.md b/website/blog/2016-09-01-jest-15.md index e7afc6369dd7..8a874cb1f893 100644 --- a/website/blog/2016-09-01-jest-15.md +++ b/website/blog/2016-09-01-jest-15.md @@ -7,7 +7,7 @@ authorFBID: 100000023028168 We spent the past year making Jest [faster](/blog/2016/03/11/javascript-unit-testing-performance), [easier to configure](/blog/2016/04/12/jest-11), [added tons of features](/blog/2016/06/22/jest-13) and built [snapshot testing](/blog/2016/07/27/jest-14). However, there were two areas where we invested very little: the CLI output and user experience. With Jest 15 we are changing the framework radically to make it easier to use both for beginners and experienced users. We are excited that our investment in Jest is now paying off: we can move fast and improve the framework for Facebook and the open source community at light-speed. Jest's goal is to come with batteries included and to require as little configuration as necessary. We recently got a chance to explain our philosophy on a [create-react-app issue](https://github.com/facebookincubator/create-react-app/pull/250#issuecomment-237098619). -The most important change to talk about is a set of [new defaults](https://github.com/facebook/jest/pull/1511). If you are an existing Jest user you will very likely need to update your configuration for Jest 15. In most cases it will simplify your setup and Jest will provide useful error messages during the upgrade. All of the new defaults can be disabled to suit your needs, but we still consider the disabled features critical for Jest in certain situations and will continue to use and support them at Facebook long-term. Our [API documentation](/docs/api) was also completely rewritten to reflect these changes. [This pull request for React](https://github.com/facebook/react/pull/7625/files) highlights some of the changes necessary for existing projects. +The most important change to talk about is a set of [new defaults](https://github.com/jestjs/jest/pull/1511). If you are an existing Jest user you will very likely need to update your configuration for Jest 15. In most cases it will simplify your setup and Jest will provide useful error messages during the upgrade. All of the new defaults can be disabled to suit your needs, but we still consider the disabled features critical for Jest in certain situations and will continue to use and support them at Facebook long-term. Our [API documentation](/docs/api) was also completely rewritten to reflect these changes. [This pull request for React](https://github.com/facebook/react/pull/7625/files) highlights some of the changes necessary for existing projects. @@ -68,7 +68,7 @@ const React2 = require('react'); React1 !== React2; // These two are separate copies of React. ``` -The call to `resetModules` wipes away the require cache. A second call to require the same module will result in a new instantiation of the same module and all of its dependencies. This feature is especially useful when dealing with modules that have side effects, like [jest-haste-map](https://github.com/facebook/jest/blob/3bbf32a239fc4aad8cc6928a787f235bd86fecac/packages/jest-haste-map/src/__tests__/index-test.js#L64). +The call to `resetModules` wipes away the require cache. A second call to require the same module will result in a new instantiation of the same module and all of its dependencies. This feature is especially useful when dealing with modules that have side effects, like [jest-haste-map](https://github.com/jestjs/jest/blob/3bbf32a239fc4aad8cc6928a787f235bd86fecac/packages/jest-haste-map/src/__tests__/index-test.js#L64). We believe it is better to put users in control so we disabled the implicit reset. Modules can be reset using `jest.resetModules()` in code and the `resetModules` option can be enabled in the configuration to bring back the previous behavior. @@ -86,7 +86,7 @@ The `setupEnvScriptFile` configuration option has been deprecated for a while. J ## Rewritten Code Coverage Support -Code coverage in Jest can be used through `jest --coverage` and requires no additional packages or configuration. Code coverage support was completely rewritten and a new `collectCoverageFrom` option was added to collect code coverage information from entire projects, including **untested files**. Note that this option uses globs as we are hoping to further simplify configuration options in the future and provide a simpler alternative to regular expressions. See Jest's [package.json](https://github.com/facebook/jest/blob/9088f6517813f6c089cf52e980d6579511dcde88/package.json#L47) for an example. +Code coverage in Jest can be used through `jest --coverage` and requires no additional packages or configuration. Code coverage support was completely rewritten and a new `collectCoverageFrom` option was added to collect code coverage information from entire projects, including **untested files**. Note that this option uses globs as we are hoping to further simplify configuration options in the future and provide a simpler alternative to regular expressions. See Jest's [package.json](https://github.com/jestjs/jest/blob/9088f6517813f6c089cf52e980d6579511dcde88/package.json#L47) for an example. ## Other Improvements @@ -102,6 +102,6 @@ A huge number of other improvements were also made: - Fix `testEnvironment` resolution to prefer `jest-environment-{name}` instead of `{name}` only. This prevents a module collision when using `jsdom` as test environment. - Improvements to Jest's own test infra by merging integration and unit tests. Code coverage is now collected for Jest. -We are happy when looking back at all the changes we have made together with the help from the community and couldn't be more excited to make Jest even better over the course of the next few months. Please [file an issue](https://github.com/facebook/jest/issues) if something isn't working as expected and send us pull requests. +We are happy when looking back at all the changes we have made together with the help from the community and couldn't be more excited to make Jest even better over the course of the next few months. Please [file an issue](https://github.com/jestjs/jest/issues) if something isn't working as expected and send us pull requests. -Next up: [Concurrent Reporter](https://github.com/facebook/jest/pull/1480). +Next up: [Concurrent Reporter](https://github.com/jestjs/jest/pull/1480). diff --git a/website/blog/2016-10-03-jest-16.md b/website/blog/2016-10-03-jest-16.md index 3e718ab2a7d4..1e5f5600d18d 100644 --- a/website/blog/2016-10-03-jest-16.md +++ b/website/blog/2016-10-03-jest-16.md @@ -76,4 +76,4 @@ Other highlights about snapshot testing: If you are using other test runners, Kenneth Skovhus built an awesome [jest-codemods](https://github.com/skovhus/jest-codemods) library that will automate the conversion for you. Codemods are awesome: they'll allow you to quickly evaluate whether Jest will work for you. Give it a try! -The full [changelog can be found on GitHub](https://github.com/facebook/jest/blob/main/CHANGELOG.md#jest-1600). Jest 16 was a true JavaScript community effort and the project now has more than 220 contributors. We thank each and every one of you for your help to make this project great. +The full [changelog can be found on GitHub](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#jest-1600). Jest 16 was a true JavaScript community effort and the project now has more than 220 contributors. We thank each and every one of you for your help to make this project great. diff --git a/website/blog/2016-12-15-2016-in-jest.md b/website/blog/2016-12-15-2016-in-jest.md index 307c7319930a..70cfd0940589 100644 --- a/website/blog/2016-12-15-2016-in-jest.md +++ b/website/blog/2016-12-15-2016-in-jest.md @@ -5,15 +5,15 @@ authorURL: http://twitter.com/cpojer authorFBID: 100000023028168 --- -2016 was a big year for JavaScript testing with Jest. In the first six months of the year we rewrote Jest and built a solid foundation to significantly improve performance and the developer experience of testing JavaScript code. We flow-typed the entire codebase, built a ton of integration tests for Jest itself and adopted [lerna](https://lernajs.io/) to turn Jest from a framework into a [_Painless JavaScript Testing platform_](https://github.com/facebook/jest/tree/main/packages). +2016 was a big year for JavaScript testing with Jest. In the first six months of the year we rewrote Jest and built a solid foundation to significantly improve performance and the developer experience of testing JavaScript code. We flow-typed the entire codebase, built a ton of integration tests for Jest itself and adopted [lerna](https://lernajs.io/) to turn Jest from a framework into a [_Painless JavaScript Testing platform_](https://github.com/jestjs/jest/tree/main/packages). The newly created [react-test-renderer](https://yarnpkg.com/en/package/react-test-renderer) finally enabled testing of react-native components. Through the jest-react-native preset (now merged directly into react-native) Jest now works out of the box for any React project and comes pre-configured in [create-react-app](https://github.com/facebookincubator/create-react-app) and [react-native](https://github.com/facebook/react-native) projects. We integrated core pieces of Jest into [react-native's packager](https://github.com/facebook/react-native/tree/main/packager/react-packager/src) and the completely new snapshot testing feature has since been used outside of Jest: It was integrated with React Storybook as “[storyshots](https://github.com/storybooks/storyshots)” and is being adopted by other test runners like [ava](https://github.com/avajs/ava/pull/1113). -The [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) project was rewritten with performance in mind to drive Jest's snapshot feature, was recently merged into Jest's monorepo and is also helpful in other [test runners](https://github.com/avajs/ava/pull/1154). Nowadays Jest is much more about collecting different ideas and solutions to testing than it is about one specific implementation of a test framework. +The [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) project was rewritten with performance in mind to drive Jest's snapshot feature, was recently merged into Jest's monorepo and is also helpful in other [test runners](https://github.com/avajs/ava/pull/1154). Nowadays Jest is much more about collecting different ideas and solutions to testing than it is about one specific implementation of a test framework. -I'd like to deeply thank all the people that have [contributed to Jest this year](https://github.com/facebook/jest/graphs/contributors?from=2016-01-01&to=2016-12-14&type=c), both from the open source community and at Facebook: Dmitrii Abramov, Cristian Carlesso, Dan Abramov, Daniel Lo Nigro, Maxim Derbin, Evan Scott, Forbes Lindesay, Keyan Zhang and 60 more people. We'd also like to welcome [Michał Pierzchała (@thymikee)](https://twitter.com/thymikee) as first official external contributor to Jest. He's been doing a great job managing the issues and PRs on the repo. If you'd like to start contributing to Jest, we have a bunch of [good first tasks](https://github.com/facebook/jest/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+bug%22) and we are always happy to help on our [discord channel](https://discord.gg/j6FKKQQrW9). +I'd like to deeply thank all the people that have [contributed to Jest this year](https://github.com/jestjs/jest/graphs/contributors?from=2016-01-01&to=2016-12-14&type=c), both from the open source community and at Facebook: Dmitrii Abramov, Cristian Carlesso, Dan Abramov, Daniel Lo Nigro, Maxim Derbin, Evan Scott, Forbes Lindesay, Keyan Zhang and 60 more people. We'd also like to welcome [Michał Pierzchała (@thymikee)](https://twitter.com/thymikee) as first official external contributor to Jest. He's been doing a great job managing the issues and PRs on the repo. If you'd like to start contributing to Jest, we have a bunch of [good first tasks](https://github.com/jestjs/jest/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+bug%22) and we are always happy to help on our [discord channel](https://discord.gg/j6FKKQQrW9). ## [repl.it](http://repl.it/) with Jest integration @@ -45,7 +45,7 @@ Here is what happened in the community in the last two months: - Emil Ong wrote about why [“TDD'ing your frontend seems pointless”](https://engineering.haus.com/why-tdding-your-frontend-feels-pointless-5f710fea7325#.pql79knnm). - Nate Hunzaker wrote about [end-to-end testing with Jest and Nightmare](https://www.viget.com/articles/acceptance-testing-react-apps-with-jest-and-nightmare). - [Using Jest with Angular just works](https://medium.com/aya-experience/testing-an-angularjs-app-with-jest-3029a613251#.h9badqevy) according to Matthieu Lux. -- A fantastic conversation about the [purpose of snapshot testing](https://github.com/facebook/jest/issues/2197) is happening right now. +- A fantastic conversation about the [purpose of snapshot testing](https://github.com/jestjs/jest/issues/2197) is happening right now. - Dmitrii made a new [music video with his metal band](https://twitter.com/abramov_dmitrii/status/806613542447157248). - [lazyspec](https://yarnpkg.com/en/package/lazyspec) can help you create smoke tests quickly if you are introducing tests to an existing codebase. - Patrick Stapfer did a lightning talk about [vim and Jest](https://twitter.com/ryyppy/status/803871975995277312). @@ -53,7 +53,7 @@ Here is what happened in the community in the last two months: ## New features, changes and fixes in Jest 17 & 18 -Jest was initially created more than five years ago and as such an old framework it has accumulated some technical debt. This is why we tend to make breaking changes more often than may seem necessary: We believe it is important to incrementally reduce technical debt to ensure that Jest as a project stays maintainable long-term. We didn't announce Jest 17 in a blog post and if you haven't upgraded to it in the last month you may find the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md) useful. +Jest was initially created more than five years ago and as such an old framework it has accumulated some technical debt. This is why we tend to make breaking changes more often than may seem necessary: We believe it is important to incrementally reduce technical debt to ensure that Jest as a project stays maintainable long-term. We didn't announce Jest 17 in a blog post and if you haven't upgraded to it in the last month you may find the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) useful. - **Breaking:** Removed `pit` in favor of `it` or `test` and `mockImpl` in favor of `jest.fn()` or `mockImplementation` . - **Breaking:** Renamed `--jsonOutputFile` to `--outputFile`. @@ -99,7 +99,7 @@ Jest was initially created more than five years ago and as such an old framework Six months ago [we shared our plans for Jest](/blog/2016/07/27/jest-14#what-s-next-for-jest) and we are happy that we were able to execute well on almost all of them. For the next six months, here is what we are planning: -- **Instant feedback:** [Nuclide](https://nuclide.io/) integration and an improved and [faster watch mode](https://github.com/facebook/jest/pull/2324#issuecomment-267149669). +- **Instant feedback:** [Nuclide](https://nuclide.io/) integration and an improved and [faster watch mode](https://github.com/jestjs/jest/pull/2324#issuecomment-267149669). - **Improved developer experience:** new mocking APIs and improved assertions. - **Better performance and memory usage:** analyze Jest and be more conscious about efficiency. - **Snapshot Improvements:** snapshot approval mode, syntax highlighting and improved `react-test-renderer` APIs. diff --git a/website/blog/2017-01-30-a-great-developer-experience.md b/website/blog/2017-01-30-a-great-developer-experience.md index 91a6c65a99e1..a59fb088108c 100644 --- a/website/blog/2017-01-30-a-great-developer-experience.md +++ b/website/blog/2017-01-30-a-great-developer-experience.md @@ -47,6 +47,6 @@ As highlighted [last month](/blog/2016/12/15/2016-in-jest), it is now possible t ## Get involved -This is just the start. Go ahead and take a look at the docs, and don't hesitate to send any feedback our way. If you find a mistake in the docs or you just want to let us know what needs to be documented better, please tweet at us at [@jestjs\_](https://twitter.com/jestjs_), [open an issue on GitHub](https://github.com/facebook/jest/issues), or send us a PR by clicking "Edit on GitHub" at the top of the doc. +This is just the start. Go ahead and take a look at the docs, and don't hesitate to send any feedback our way. If you find a mistake in the docs or you just want to let us know what needs to be documented better, please tweet at us at [@jestjs\_](https://twitter.com/jestjs_), [open an issue on GitHub](https://github.com/jestjs/jest/issues), or send us a PR by clicking "Edit on GitHub" at the top of the doc. We're really excited for the year ahead and can't wait to hear from you! diff --git a/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md b/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md index 17b282aff06d..3d2094b47521 100644 --- a/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md +++ b/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md @@ -9,7 +9,7 @@ Today we are pleased to ship version 19 of the Jest testing platform. It's the b ## Immersive Watch Mode -We [completely rewrote the watch mode](https://github.com/facebook/jest/pull/2362) to make it instant and more extensible. As a result, the experience of using it really is immersive: tests re-run instantly after a file change and we made it easy to select the right tests. +We [completely rewrote the watch mode](https://github.com/jestjs/jest/pull/2362) to make it instant and more extensible. As a result, the experience of using it really is immersive: tests re-run instantly after a file change and we made it easy to select the right tests. @@ -81,19 +81,19 @@ We now also error on invalid CLI arguments instead of ignoring them. But we've g - [`expect.stringContaining`](/docs/expect#expectstringcontainingstring) - [`jest.spyOn`](/docs/jest-object#jestspyonobject-methodname) -We're close to almost full feature parity with the `expect` npm package. [Michael Jackson](https://twitter.com/mjackson), the author of the package, agreed to [donate](https://github.com/facebook/jest/issues/1679) it to the Jest project, which means that `jest-matchers` will be renamed to `expect`. Since our version of `expect` is not intended to be fully compatible, [Christopher Chedeau](https://twitter.com/Vjeux) is working on a codemod to make the transition painless. Christopher also worked on a number of improvements to `jest-matchers` which enables it to be used outside of Jest and even [works inside browsers](https://github.com/facebook/jest/pull/2795). +We're close to almost full feature parity with the `expect` npm package. [Michael Jackson](https://twitter.com/mjackson), the author of the package, agreed to [donate](https://github.com/jestjs/jest/issues/1679) it to the Jest project, which means that `jest-matchers` will be renamed to `expect`. Since our version of `expect` is not intended to be fully compatible, [Christopher Chedeau](https://twitter.com/Vjeux) is working on a codemod to make the transition painless. Christopher also worked on a number of improvements to `jest-matchers` which enables it to be used outside of Jest and even [works inside browsers](https://github.com/jestjs/jest/pull/2795). -## [eslint-plugin-jest](https://github.com/facebook/jest/tree/main/packages/eslint-plugin-jest) – our very own ESLint plugin +## [eslint-plugin-jest](https://github.com/jestjs/jest/tree/main/packages/eslint-plugin-jest) – our very own ESLint plugin Thanks to [Jonathan Kim](https://twitter.com/jonnykim) Jest finally has its own official ESLint plugin. It exposes three rules: -- [no-disabled-tests](https://github.com/facebook/jest/blob/main/packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md) - this rule prevents you from accidentally committing disabled tests. -- [no-focused-tests](https://github.com/facebook/jest/blob/main/packages/eslint-plugin-jest/docs/rules/no-focused-tests.md) - this rule prevents you from committing focused tests which would disable all other tests in the same suite. -- [no-identical-title](https://github.com/facebook/jest/blob/main/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) - disallows identical titles in test names. +- [no-disabled-tests](https://github.com/jestjs/jest/blob/main/packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md) - this rule prevents you from accidentally committing disabled tests. +- [no-focused-tests](https://github.com/jestjs/jest/blob/main/packages/eslint-plugin-jest/docs/rules/no-focused-tests.md) - this rule prevents you from committing focused tests which would disable all other tests in the same suite. +- [no-identical-title](https://github.com/jestjs/jest/blob/main/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) - disallows identical titles in test names. You can install it using `npm install --save-dev eslint-plugin-jest` or `yarn add --dev eslint eslint-plugin-jest` and it can be enabled by adding `{"plugins": ["jest"]}` to your eslint configuration. -## New public package: [jest-validate](https://github.com/facebook/jest/tree/main/packages/jest-validate) +## New public package: [jest-validate](https://github.com/jestjs/jest/tree/main/packages/jest-validate) While we refactored the validation and normalization code for Jest's configuration, we were so happy with the new error messaging that we extracted it to its own module to share it with everyone. With Jest 19 we welcome `jest-validate` to our self-sustained packages family. @@ -135,12 +135,12 @@ The homepage was completely redesigned to be more descriptive of what Jest is ab - Stephen Scott wrote a detailed article about [testing React components](https://medium.freecodecamp.com/the-right-way-to-test-react-components-548a4736ab22) in which he weighs the pros and cons of different approaches. - [Using Jest with vue.js](https://medium.com/@kentaromiura_the_js_guy/jest-for-all-episode-1-vue-js-d616bccbe186#.r8ryxlw98) got a lot easier after reading Cristian Carlesso's blog post. - [Michele Bertoli wrote a book about React Design Patterns and Best Practices](https://twitter.com/cpojer/status/825004258219130880) which features an entire section about Jest. -- Improved `--notify` command that shows an operating system notification which [can now also re-run tests from the notification](https://github.com/facebook/jest/pull/2727). This is actually a Jest feature and we are just checking if you are still reading this blog post. +- Improved `--notify` command that shows an operating system notification which [can now also re-run tests from the notification](https://github.com/jestjs/jest/pull/2727). This is actually a Jest feature and we are just checking if you are still reading this blog post. - Jest is now part of [react-boilerplate](https://twitter.com/mxstbr/status/820326656439177217). - Read about the [hidden powers of Jest's matchers](https://medium.com/@boriscoder/the-hidden-power-of-jest-matchers-f3d86d8101b0#.pn10z1pzx). -Finally, we are happy to announce that the [ava](https://github.com/avajs/ava) test runner has adopted parts of the Jest platform and is now shipping with basic [snapshot support](https://github.com/avajs/ava#snapshot-testing) and is using [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format). Consolidating test infrastructure makes it easier to learn how to test applications and enables us to share best practices. We are looking forward to see what we can learn from existing test libraries in the future. +Finally, we are happy to announce that the [ava](https://github.com/avajs/ava) test runner has adopted parts of the Jest platform and is now shipping with basic [snapshot support](https://github.com/avajs/ava#snapshot-testing) and is using [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format). Consolidating test infrastructure makes it easier to learn how to test applications and enables us to share best practices. We are looking forward to see what we can learn from existing test libraries in the future. -The full [changelog can be found on GitHub](https://github.com/facebook/jest/blob/main/CHANGELOG.md#jest-1900). Jest 19 was a true JavaScript community effort with [17 people who contributed](https://github.com/facebook/jest/graphs/contributors?from=2016-12-23&to=2017-02-21&type=c) to this release. We thank each and every one of you for your help to make this project great. +The full [changelog can be found on GitHub](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#jest-1900). Jest 19 was a true JavaScript community effort with [17 people who contributed](https://github.com/jestjs/jest/graphs/contributors?from=2016-12-23&to=2017-02-21&type=c) to this release. We thank each and every one of you for your help to make this project great. _This blog post was written by [Rogelio Guzman](https://twitter.com/rogeliog) and [Michał Pierzchała](https://twitter.com/thymikee)._ diff --git a/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md b/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md index aa7ed8bbe447..0764f16dbf0a 100644 --- a/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md +++ b/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md @@ -78,7 +78,7 @@ As with every major release, we are making a number of breaking changes to make - **Translations:** We are now asking for your help to [translate the Jest documentation](https://crowdin.com/project/jest-v2) to make it easier for people to learn how to use Jest. - **Custom Reporters:** Jest now supports custom test reporters through the `reporters` configuration option. You can finally customize the output of Jest as well as integrate it with other tools by generating reports in formats such as XML. [See documentation](/docs/configuration#reporters-array-modulename-modulename-options). - **Codebase Health:** It was only possible iterate so quickly in Jest because we spent a significant amount of time on the health of the codebase. We were one of the early adopters of [prettier](https://github.com/prettier/prettier), we notably increased flow coverage, forked Jasmine to improve our test runner library and we rewrote and refactored significant portions of Jest itself to set up Jest for success in the future. -- **Bugfixes:** As always, we made plenty of bugfixes in Jest. The full changelog can be found in the [Jest repository](https://github.com/facebook/jest/blob/main/CHANGELOG.md#jest-2000). +- **Bugfixes:** As always, we made plenty of bugfixes in Jest. The full changelog can be found in the [Jest repository](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#jest-2000). ## Talks about Jest @@ -87,4 +87,4 @@ Recently the Jest core team and other contributors started to talk more about Je - Rogelio Guzman did a talk about [Jest Snapshots and Beyond](https://www.youtube.com/watch?time_continue=416&v=HAuXJVI_bUs) at React Conf. - I spoke about [Building High-Quality JavaScript Tools](https://developers.facebook.com/videos/f8-2017/building-high-quality-javascript-tools/) at Facebook's F8 conference. -_As always, this release couldn't have been possible without you, the JavaScript community. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together. If you'd like to contribute to Jest, please don't hesitate to reach out to us on [GitHub](https://github.com/facebook/jest) or on [Discord](https://discord.gg/j6FKKQQrW9)._ +_As always, this release couldn't have been possible without you, the JavaScript community. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together. If you'd like to contribute to Jest, please don't hesitate to reach out to us on [GitHub](https://github.com/jestjs/jest) or on [Discord](https://discord.gg/j6FKKQQrW9)._ diff --git a/website/blog/2017-12-18-jest-22.md b/website/blog/2017-12-18-jest-22.md index 7d5ebb915953..f1fd8367f77f 100644 --- a/website/blog/2017-12-18-jest-22.md +++ b/website/blog/2017-12-18-jest-22.md @@ -5,7 +5,7 @@ authorURL: https://github.com/SimenB authorFBID: 100003004880942 --- -Today we are announcing a new major version of Jest which refines almost all parts of Jest to provide a more solid testing foundation. Together with the Jest community we made a number of changes across the board that will help you get more out of Jest. We are also graduating the custom runners feature out of the experimental stage and added a new package, `jest-worker`, for parallelizing work across multiple processes. We have compiled a list of highlights below but make sure to check out the (as always) [massive changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md). +Today we are announcing a new major version of Jest which refines almost all parts of Jest to provide a more solid testing foundation. Together with the Jest community we made a number of changes across the board that will help you get more out of Jest. We are also graduating the custom runners feature out of the experimental stage and added a new package, `jest-worker`, for parallelizing work across multiple processes. We have compiled a list of highlights below but make sure to check out the (as always) [massive changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md). @@ -67,11 +67,11 @@ When [Puppeteer](https://github.com/GoogleChrome/puppeteer/), a way of programma ## Experimental Leak Detection -We added an experimental `--detectLeaks` setting to Jest that will let you know if your internal environment instance is leaked after a test execution. It will also warn you when your test suite tries to require a file after the test has finished, meaning you forgot to wait for all async operations or left something not properly cleaned. This will however not discover leaks in user land code, only in test land code; although the technology used behind it can help you (see `jest-leak-detector`). If you are reporting a bug about Jest's memory usage, please provide a repro where `--detectLeaks` will make the test suite fail. We [started building a better sandboxing mechanism](https://github.com/facebook/jest/pull/4970) for Jest but it's not ready yet to be enabled by default. If you'd like to help, please reach out to us on discord! +We added an experimental `--detectLeaks` setting to Jest that will let you know if your internal environment instance is leaked after a test execution. It will also warn you when your test suite tries to require a file after the test has finished, meaning you forgot to wait for all async operations or left something not properly cleaned. This will however not discover leaks in user land code, only in test land code; although the technology used behind it can help you (see `jest-leak-detector`). If you are reporting a bug about Jest's memory usage, please provide a repro where `--detectLeaks` will make the test suite fail. We [started building a better sandboxing mechanism](https://github.com/jestjs/jest/pull/4970) for Jest but it's not ready yet to be enabled by default. If you'd like to help, please reach out to us on discord! ## Watch Mode Refinements -When using watch mode, there is now a way to [focus only on tests that previously failed](https://github.com/facebook/jest/pull/4886). In this mode, Jest will not re-run previously passing tests which should help you iron out all test failures. Additionally, [we added a plugin system to watch mode](https://github.com/facebook/jest/pull/4841). By adding modules to `watchPlugins` in your configuration you can extend the features of the watch mode. +When using watch mode, there is now a way to [focus only on tests that previously failed](https://github.com/jestjs/jest/pull/4886). In this mode, Jest will not re-run previously passing tests which should help you iron out all test failures. Additionally, [we added a plugin system to watch mode](https://github.com/jestjs/jest/pull/4841). By adding modules to `watchPlugins` in your configuration you can extend the features of the watch mode. ## Babel 7 support @@ -110,7 +110,7 @@ exports[`my mocking test 1`] = ` Jest 21 was released back in September, and we unfortunately never got around to write a blog post. So here is a quick summary of the main changes in version 21: -1. **Use expect and jest-mock in the browser:** [Michael Jackson](https://github.com/mjackson) donated his excellent [`expect`](https://github.com/mjackson/expect) package to the Jest project. As part of that transition, the Jest core team, with much help from [Kenneth Skovhus](https://github.com/skovhus/), made both `jest-matchers` (renamed to `expect`) and `jest-mock` work in browsers. This means that while you cannot use Jest itself in browsers ([yet](https://github.com/facebook/jest/issues/848)), you can use its awesome assertions and mocks for instance as replacements for Chai and Sinon running in Mocha tests. If you are migrating from earlier `expect` to the new Jest-powered `expect`, you can use [`jest-codemods`](https://github.com/skovhus/jest-codemods/) to automate the migration. +1. **Use expect and jest-mock in the browser:** [Michael Jackson](https://github.com/mjackson) donated his excellent [`expect`](https://github.com/mjackson/expect) package to the Jest project. As part of that transition, the Jest core team, with much help from [Kenneth Skovhus](https://github.com/skovhus/), made both `jest-matchers` (renamed to `expect`) and `jest-mock` work in browsers. This means that while you cannot use Jest itself in browsers ([yet](https://github.com/jestjs/jest/issues/848)), you can use its awesome assertions and mocks for instance as replacements for Chai and Sinon running in Mocha tests. If you are migrating from earlier `expect` to the new Jest-powered `expect`, you can use [`jest-codemods`](https://github.com/skovhus/jest-codemods/) to automate the migration. 2. **MIT License:** We changed Jest's license to MIT. _Yay!_ 3. **Fail test suites on async errors:** Jest used to have a bug that made it crash when errors were thrown in certain parts of async code. This was fixed by community contributors. 4. **Faster startup:** With Jest 21 we fine tuned Jest's startup to be more than 50% faster. The large overhead of Jest when running it on a small and fast test was always an issue for us and now this shouldn't be a reason to hold you back from using Jest any longer. diff --git a/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md b/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md index 88b758e754ff..132594a4e49d 100644 --- a/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md +++ b/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md @@ -13,7 +13,7 @@ Here's are some of the Jest 23 highlights and breaking changes. -For a full list see the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md). +For a full list see the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md). ## Interactive Snapshot Mode @@ -130,4 +130,4 @@ Full talk is available [here](https://www.youtube.com/watch?v=cAKYQpTC7MA). The turnout was amazing, and we were able to meet a lot of the London-based community in person. Thank you to everyone who joined us and for your continued support! Stay tuned for our next post which will outline the Jest Open Collective and the plans we have for the future. -_As always, this release couldn't have been possible without you, the JavaScript community. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together. If you'd like to contribute to Jest, please don't hesitate to reach out to us on_ _[GitHub](https://github.com/facebook/jest) or on_ _[Discord](https://discord.gg/j6FKKQQrW9)._ +_As always, this release couldn't have been possible without you, the JavaScript community. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together. If you'd like to contribute to Jest, please don't hesitate to reach out to us on_ _[GitHub](https://github.com/jestjs/jest) or on_ _[Discord](https://discord.gg/j6FKKQQrW9)._ diff --git a/website/blog/2019-01-25-jest-24-refreshing-polished-typescript-friendly.md b/website/blog/2019-01-25-jest-24-refreshing-polished-typescript-friendly.md index 2083a34edebe..580fec8b6668 100644 --- a/website/blog/2019-01-25-jest-24-refreshing-polished-typescript-friendly.md +++ b/website/blog/2019-01-25-jest-24-refreshing-polished-typescript-friendly.md @@ -7,7 +7,7 @@ authorFBID: 100003004880942 Today we are happy to announce the next major release of Jest - version 24! It's been 4 months since the last minor release, and 8 months since Jest 23, so this upgrade is a big one, with something for everyone! Highlights include built-in support for TypeScript by upgrading the Jest internals to Babel 7, fixing some long-standing issues with missing console output and performance issues when computing large diffs, and a brand new sparkling website. ✨ -For a full list of all changes see the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md). +For a full list of all changes see the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md). @@ -15,7 +15,7 @@ For a full list of all changes see the [changelog](https://github.com/facebook/j [@orta](https://twitter.com/orta) has provided a beautiful redesign of Jest's website, which has been implemented by community members [@montogeek](https://twitter.com/montogeek) and [@brainkim](https://github.com/brainkim). -The aim of the redesign was to highlight more of what makes Jest awesome, and to decouple the idea that Jest is primarily a tool for testing React apps - you can use Jest with all sorts of projects and we want to make that obvious. You can read more about the ideas behind the redesign in [this issue](https://github.com/facebook/jest/issues/7265). +The aim of the redesign was to highlight more of what makes Jest awesome, and to decouple the idea that Jest is primarily a tool for testing React apps - you can use Jest with all sorts of projects and we want to make that obvious. You can read more about the ideas behind the redesign in [this issue](https://github.com/jestjs/jest/issues/7265). ## TypeScript support @@ -51,7 +51,7 @@ test.todo('missing options should be normalized'); When tests fail, you need to make confident and correct decisions which changes are expected progress and which changes are unexpected regressions. It is especially important not to miss a few regressions hidden among much progress. Jest 24 makes reports when assertions fail more clear and concise for several matchers. Because the effort will continue in Jest 25, you might notice some temporary inconsistencies. If your tests never fail, then you won't get to see them - for the rest of us, it'll be easier to debug why something isn't working as expected. Thanks for the hard work by [@ittordepam](https://twitter.com/ittordepam) and other contributors from the community. -You can see these changes across all these PRs: [7621](https://github.com/facebook/jest/pull/7621), [7557](https://github.com/facebook/jest/pull/7557), [7448](https://github.com/facebook/jest/pull/7448), [7325](https://github.com/facebook/jest/pull/7325), [7241](https://github.com/facebook/jest/pull/7241), [7152](https://github.com/facebook/jest/pull/7152), [7125](https://github.com/facebook/jest/pull/7125), [7107](https://github.com/facebook/jest/pull/7107), [6961](https://github.com/facebook/jest/pull/6961). +You can see these changes across all these PRs: [7621](https://github.com/jestjs/jest/pull/7621), [7557](https://github.com/jestjs/jest/pull/7557), [7448](https://github.com/jestjs/jest/pull/7448), [7325](https://github.com/jestjs/jest/pull/7325), [7241](https://github.com/jestjs/jest/pull/7241), [7152](https://github.com/jestjs/jest/pull/7152), [7125](https://github.com/jestjs/jest/pull/7125), [7107](https://github.com/jestjs/jest/pull/7107), [6961](https://github.com/jestjs/jest/pull/6961). Examples: @@ -71,27 +71,27 @@ Mock function not called We've fixed a couple of really old issues in this release. -The first one we'd like to highlight is `console.log` statements going missing. Jest intercepts and collects all logs in order to give you a stack trace to them, as well as provide them to reporters so you can handle them however you want. However, this has led to an issue where they have simply been missing in certain edge cases. Luckily for Jest 24, [@spion](https://twitter.com/spion) has [stepped up](https://github.com/facebook/jest/pull/6871) and fixed this issue. Thank you very much! +The first one we'd like to highlight is `console.log` statements going missing. Jest intercepts and collects all logs in order to give you a stack trace to them, as well as provide them to reporters so you can handle them however you want. However, this has led to an issue where they have simply been missing in certain edge cases. Luckily for Jest 24, [@spion](https://twitter.com/spion) has [stepped up](https://github.com/jestjs/jest/pull/6871) and fixed this issue. Thank you very much! -The second one is an issue where Jest runs out of memory if the difference in serialization of expected and received value has a huge number of insertion changes (either unexpected because of mistake in test or defect in serializer or expected because of temporary failures during test-driven development). [@ittordepam](https://twitter.com/ittordepam) has [replaced](https://github.com/facebook/jest/pull/6961) the previous diffing algorithm with `diff-sequences` package, which should fix this issue because it uses the theoretical minimum amount of memory. It opens up possibility for word-diffs in the future, similar to what [git provides](https://git-scm.com/docs/git-diff#git-diff---word-diffltmodegt). Please see [this PR](https://github.com/facebook/jest/pull/4619) and don't hesitate to reach out if you want to help make that happen! +The second one is an issue where Jest runs out of memory if the difference in serialization of expected and received value has a huge number of insertion changes (either unexpected because of mistake in test or defect in serializer or expected because of temporary failures during test-driven development). [@ittordepam](https://twitter.com/ittordepam) has [replaced](https://github.com/jestjs/jest/pull/6961) the previous diffing algorithm with `diff-sequences` package, which should fix this issue because it uses the theoretical minimum amount of memory. It opens up possibility for word-diffs in the future, similar to what [git provides](https://git-scm.com/docs/git-diff#git-diff---word-diffltmodegt). Please see [this PR](https://github.com/jestjs/jest/pull/4619) and don't hesitate to reach out if you want to help make that happen! ## Other highlights - We have some improvements for `globalSetup` and `globalTeardown` as well - code transformation will be applied to them similar to `setupFiles` and they are now supported as part of `projects`. -- You can [configure](https://github.com/facebook/jest/pull/6143) Jest's snapshot location, this is mainly useful if you are building tools which use Jest in a larger build process. +- You can [configure](https://github.com/jestjs/jest/pull/6143) Jest's snapshot location, this is mainly useful if you are building tools which use Jest in a larger build process. - A quirk of Jest's CLI has been that while some flags and options have been camel cased (such as `runInBand`), others have not been (such as `no-cache`). In Jest 24, both are recognized, meaning you can write your CLI arguments however you want. - We've renamed `setupTestFrameworkScriptFile` to `setupFilesAfterEnv`, and made it into an array. We hope this will make it more obvious what the options is for. We have plans to further overhaul the configuration in the next major, see the paragraph in the section below. - To reduce the amount of magic Jest performs to “just work™”, in this release we decided to drop automatic injection of `regenerator-runtime`, which is sometimes used in compiled async code. Including `regenerator-runtime` is not always necessary and we believe it's the user's responsibility to include it if it's needed. If you use `@babel/preset-env` with `targets` set to a modern Node version (e.g. Node 6+) you will not need to include it. Please see our [Using Babel docs](/docs/getting-started#using-babel) for more information. -- Node.js 10 came with an experimental module [called `worker_threads`](https://nodejs.org/api/worker_threads.html), which is similar to Worker threads in the browser. `jest-worker`, part of the [Jest platform](/docs/jest-platform), will be able to use `worker_threads` if available instead of `child_process`, which makes it even faster! [Benchmarks](https://github.com/facebook/jest/pull/6676) show a 50% improvement. Due to its experimental nature, it's not enabled when using Jest as a test runner, but you can use it in your own projects today! We plan to enable it by default when it's promoted from experimental status in Node.js. +- Node.js 10 came with an experimental module [called `worker_threads`](https://nodejs.org/api/worker_threads.html), which is similar to Worker threads in the browser. `jest-worker`, part of the [Jest platform](/docs/jest-platform), will be able to use `worker_threads` if available instead of `child_process`, which makes it even faster! [Benchmarks](https://github.com/jestjs/jest/pull/6676) show a 50% improvement. Due to its experimental nature, it's not enabled when using Jest as a test runner, but you can use it in your own projects today! We plan to enable it by default when it's promoted from experimental status in Node.js. ## Breaking Changes -While all breaking changes are listed in the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md), there's a few of them that are worth highlighting: +While all breaking changes are listed in the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md), there's a few of them that are worth highlighting: - We've upgraded to Micromatch 3. While this might not affect every user, it is stricter in its parsing of globs than version 2, which is used in Jest 23. Please read through [this](https://github.com/micromatch/micromatch/issues/133#issuecomment-404211484) and linked issues for examples of invalid globs in case you have problems. - We've removed code remnants that was needed for Node 4. It was previously technically possible to run Jest 23 on Node 4 - that is no longer possible without polyfilling and transpiling. -- Some changes to serialization of mock functions in snapshots - make sure to double check your updated snapshots after upgrading. Related [PR](https://github.com/facebook/jest/pull/6381). -- Jest no longer automatically injects `regenerator-runtime` - if you get errors concerning it, make sure to configure Babel to properly transpile `async` functions, using e.g. `@babel/preset-env`. Related [PR](https://github.com/facebook/jest/pull/7595). +- Some changes to serialization of mock functions in snapshots - make sure to double check your updated snapshots after upgrading. Related [PR](https://github.com/jestjs/jest/pull/6381). +- Jest no longer automatically injects `regenerator-runtime` - if you get errors concerning it, make sure to configure Babel to properly transpile `async` functions, using e.g. `@babel/preset-env`. Related [PR](https://github.com/jestjs/jest/pull/7595). ## The future @@ -99,11 +99,11 @@ We are incredibly humbled by the results in [State Of JS 2018](https://2018.stat We are very thankful for the trust in us shown by the community, and hope to build on it in the future. We will ensure Jest 24 and future releases will continue to build upon this incredible foundation, and continue to be an integral part of JavaScript developers' toolkits. -This has been the first release where we have explored the idea of using our Open Collective funding to create bug bounties. This worked well in getting non-core developers involved in the implementation of the new landing page, and we're optimistic for a long running bug where Jest globals [are mismatched](https://github.com/facebook/jest/issues/2549) from Node globals. We'd like to do more, if you have a pet bug that's a good candidate for our bounty program, please let us know. In the meantime, you can find all the tickets with a bounty via [the issue label](https://github.com/facebook/jest/labels/Has%20Bounty). +This has been the first release where we have explored the idea of using our Open Collective funding to create bug bounties. This worked well in getting non-core developers involved in the implementation of the new landing page, and we're optimistic for a long running bug where Jest globals [are mismatched](https://github.com/jestjs/jest/issues/2549) from Node globals. We'd like to do more, if you have a pet bug that's a good candidate for our bounty program, please let us know. In the meantime, you can find all the tickets with a bounty via [the issue label](https://github.com/jestjs/jest/labels/Has%20Bounty). -We have already started to make plans for the next release of Jest 25, with the biggest planned feature being an overhaul of our configuration, which is pretty hard to grok, mainly because of overlapping option and mixing globs and regular expressions. Feedback on how you want Jest's configuration to look is very much welcome, and can be submitted in [this issue](https://github.com/facebook/jest/issues/7185). +We have already started to make plans for the next release of Jest 25, with the biggest planned feature being an overhaul of our configuration, which is pretty hard to grok, mainly because of overlapping option and mixing globs and regular expressions. Feedback on how you want Jest's configuration to look is very much welcome, and can be submitted in [this issue](https://github.com/jestjs/jest/issues/7185). -You might also have heard that we are planning to migrate the code base from Flow to TypeScript. We are hopeful that this migration will enable even more contributors to jump in and help make 2019 even better for JavaScript testing. 🚀 The plan is to land this in a minor release in the not too distant future. Feedback on this choice can be added to [the RFC](https://github.com/facebook/jest/pull/7554). +You might also have heard that we are planning to migrate the code base from Flow to TypeScript. We are hopeful that this migration will enable even more contributors to jump in and help make 2019 even better for JavaScript testing. 🚀 The plan is to land this in a minor release in the not too distant future. Feedback on this choice can be added to [the RFC](https://github.com/jestjs/jest/pull/7554). Lastly, if you've ever wondered about how Jest is built, [@cpojer](https://twitter.com/cpojer) has recorded a video with an architectural overview of how Jest is put together under the hood. Feel free to reach out if you have any further questions about it. The video is available on our [website](/docs/architecture). diff --git a/website/blog/2020-01-21-jest-25.md b/website/blog/2020-01-21-jest-25.md index 73a77367f21e..273ccf129106 100644 --- a/website/blog/2020-01-21-jest-25.md +++ b/website/blog/2020-01-21-jest-25.md @@ -7,7 +7,7 @@ authorFBID: 100003004880942 Jest 25 is laying the groundwork for many major changes in the future. As such, we kept breaking changes to a minimum, but internal architecture changes may require attention during the upgrade. The main changes are an upgrade of JSDOM from v11 to v15, 10-15% faster test runs, a new diff view for outdated snapshots and dropped Node 6 support. -There has been more than 200 commits since Jest 24.9 by more than 80 different contributors, so as always, take a look at the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md) for a full list of changes. +There has been more than 200 commits since Jest 24.9 by more than 80 different contributors, so as always, take a look at the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) for a full list of changes. @@ -70,28 +70,28 @@ Here are some reasons why we chose unique colors: The difference in hue from magenta at 300° to teal/cyan/aqua at 180° gives better color vision accessibility and the light background tint for changed lines gives consistent contrast on light and dark themes. -If you maintain a command line tool, you might find inspiration to improve its accessibility in [#9132](https://github.com/facebook/jest/pull/9132). +If you maintain a command line tool, you might find inspiration to improve its accessibility in [#9132](https://github.com/jestjs/jest/pull/9132). ## ECMAScript Modules support Node 13 has unflagged ESM support, and we have started a tiny bit working towards native support in Jest. Jest 25 includes support for `jest.config.cjs` and `jest.config.mjs` configuration files, but tests themselves cannot yet be written using ESM without something like Babel or TypeScript transforming it into CJS. -The APIs Jest will use are still flagged and experimental, so don't expect support right away. These APIs are something the [Node.js Modules team](https://github.com/nodejs/modules) is actively working on, and we'll be keeping an eye on it moving forward and experiment with them so we can provide feedback. You can subscribe to [this issue](https://github.com/facebook/jest/issues/9430) to get any updates about the implementation status in Jest. +The APIs Jest will use are still flagged and experimental, so don't expect support right away. These APIs are something the [Node.js Modules team](https://github.com/nodejs/modules) is actively working on, and we'll be keeping an eye on it moving forward and experiment with them so we can provide feedback. You can subscribe to [this issue](https://github.com/jestjs/jest/issues/9430) to get any updates about the implementation status in Jest. ## Other improvements and updates -- Jest has passed [1000 unique contributors](https://github.com/facebook/jest/graphs/contributors). This is an incredible milestone! Thank you to everybody who helps us make testing as delightful as possible. +- Jest has passed [1000 unique contributors](https://github.com/jestjs/jest/graphs/contributors). This is an incredible milestone! Thank you to everybody who helps us make testing as delightful as possible. - Thanks to community member [Josh Rosenstein](https://github.com/JoshRosenstein), Jest now comes with support for `BigInt` in most matchers, such as `toBeGreaterThan`. Jest will also understand bigint literals out of the box. - Jest’s feature `--detect-leaks` has been broken for Node 12 and newer - this has been fixed in Jest 25. -- As announced in the blog post for Jest 24, Jest’s code base has been rewritten in TypeScript - this work was completed in Jest 24.3. So if you use any of Jest’s individual parts, you should get great IDE integration. Looking forward, we really want to make Jest mocks play nicer with type systems, and we’d love the community’s help with this. Please chime in [here](https://github.com/facebook/jest/issues/7832) with ideas and send PRs! We’ll also be investigating moving the typings for using Jest as a test runner from DefinitelyTyped into Jest itself. +- As announced in the blog post for Jest 24, Jest’s code base has been rewritten in TypeScript - this work was completed in Jest 24.3. So if you use any of Jest’s individual parts, you should get great IDE integration. Looking forward, we really want to make Jest mocks play nicer with type systems, and we’d love the community’s help with this. Please chime in [here](https://github.com/jestjs/jest/issues/7832) with ideas and send PRs! We’ll also be investigating moving the typings for using Jest as a test runner from DefinitelyTyped into Jest itself. - The `jest-diff` package now exports functions like `diffLinesUnified` and `diffStringsUnified` which have configuration options, so other applications can format differences in a custom way. For more information and code examples, see its new `README.md` file in the Jest repository or on package repositories. - Thanks to community member [Wei An Yen](https://github.com/WeiAnAn), Jest will no longer highlight passing asymmetric matchers in expectation errors. This has been a long-standing pain point with asymmetric matchers and we're very happy it's finally solved. - For the second year running, Jest won the Highest Satisfaction award from [State of JS](https://2019.stateofjs.com/awards/). We are incredibly grateful for the support from the community, and hope we can build on this momentum to make 2020 even better! ## Plans for the future -- Jest’s configuration is vast and somewhat clunky - there is often _at least_ two ways of doing the same thing, oftentimes even more. For Jest 26 we hope to condense the config down, and make it more predictable. See this [issue](https://github.com/facebook/jest/issues/7185) for details. -- We also hope to be able to provide a proper programmatic API for running Jest, to make integration into IDEs and other tooling easier. Please see [this](https://github.com/facebook/jest/issues/5048) tracking issue. -- There’s been an open PR for adding Lolex as an implementation of Jest’s fake timers since December 2017. While we’re not adding it to any public APIs in Jest 25, support for it is technically included and you we're looking into how to expose this so people can test and experiment with it. Using it means you can mock out `Date` and other timer function Jest currently doesn’t touch. Note that this should be considered experimental, and a proper API support will come in a later release. Follow [this PR](https://github.com/facebook/jest/pull/7776) for the latest updates on the status. +- Jest’s configuration is vast and somewhat clunky - there is often _at least_ two ways of doing the same thing, oftentimes even more. For Jest 26 we hope to condense the config down, and make it more predictable. See this [issue](https://github.com/jestjs/jest/issues/7185) for details. +- We also hope to be able to provide a proper programmatic API for running Jest, to make integration into IDEs and other tooling easier. Please see [this](https://github.com/jestjs/jest/issues/5048) tracking issue. +- There’s been an open PR for adding Lolex as an implementation of Jest’s fake timers since December 2017. While we’re not adding it to any public APIs in Jest 25, support for it is technically included and you we're looking into how to expose this so people can test and experiment with it. Using it means you can mock out `Date` and other timer function Jest currently doesn’t touch. Note that this should be considered experimental, and a proper API support will come in a later release. Follow [this PR](https://github.com/jestjs/jest/pull/7776) for the latest updates on the status. Happy Jesting! 🃏 diff --git a/website/blog/2020-05-05-jest-26.md b/website/blog/2020-05-05-jest-26.md index d0b3f8cc1c75..e3eae8dc6280 100644 --- a/website/blog/2020-05-05-jest-26.md +++ b/website/blog/2020-05-05-jest-26.md @@ -11,11 +11,11 @@ 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)) +- `[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/jestjs/jest/pull/9945)) > **Migration**: With this change, we are pushing the responsibility to bundle the affected packages to the users, rather than Jest providing them out of the box, since they know their target environments best. If you want it back, we're open to shipping these as separate packages. PRs welcome! -- `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/facebook/jest/pull/9943)) +- `[jest-config, jest-resolve]` Remove support for `browser` field ([#9943](https://github.com/jestjs/jest/pull/9943)) > **Migration**: Install `browser-resolve` module and use the following configuration: @@ -34,7 +34,7 @@ We are now beginning to address this shortcoming and are working on reducing Jes module.exports = browserResolve.sync; ``` -- TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/facebook/jest/pull/9823)) +- TypeScript definitions requires a minimum of TypeScript v3.8 ([#9823](https://github.com/jestjs/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). @@ -80,19 +80,19 @@ Caveats: ## Native ESM support -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). +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/jestjs/jest/issues/9430), or browse all issues with that label [ES Modules](https://github.com/jestjs/jest/labels/ES%20Modules). ## 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)) +- Dropped support for Node 8 ([#9423](https://github.com/jestjs/jest/pull/9423)) +- `[jest-environment-jsdom]` Upgrade `jsdom` to v16 ([#9606](https://github.com/jestjs/jest/pull/9606)) +- `[jest-runtime]` Remove long-deprecated `require.requireActual` and `require.requireMock` methods ([#9854](https://github.com/jestjs/jest/pull/9854)) +- `[jest-haste-map]` Removed `providesModuleNodeModules` ([#8535](https://github.com/jestjs/jest/pull/8535)) +- `[jest-circus]` Fail tests if a test takes a done callback and have return values ([#9129](https://github.com/jestjs/jest/pull/9129)) +- `[jest-circus]` Throw a proper error if a test / hooks is defined asynchronously ([#8096](https://github.com/jestjs/jest/pull/8096)) ## Stay Safe -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). +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/jestjs/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. diff --git a/website/blog/2021-03-09-jest-website-upgrade.md b/website/blog/2021-03-09-jest-website-upgrade.md index e68b3657e1a1..685250f7c77d 100644 --- a/website/blog/2021-03-09-jest-website-upgrade.md +++ b/website/blog/2021-03-09-jest-website-upgrade.md @@ -46,4 +46,4 @@ In localized pages, the edit button now links directly to Crowdin. Thanks to all the contributors that supported or reviewed this migration: [Simen](https://github.com/SimenB), [Orta](https://github.com/orta), [Joel](https://github.com/JoelMarcey), [Kristoffer](https://github.com/merceyz)... -Please report any problem on the [migration issue](https://github.com/facebook/jest/pull/11021). +Please report any problem on the [migration issue](https://github.com/jestjs/jest/pull/11021). diff --git a/website/blog/2021-05-25-jest-27.md b/website/blog/2021-05-25-jest-27.md index f53ebaf33867..01ac5b96108e 100644 --- a/website/blog/2021-05-25-jest-27.md +++ b/website/blog/2021-05-25-jest-27.md @@ -13,26 +13,26 @@ With the first major change of defaults since the [New Defaults for Jest](/blog/ ## Feature updates -Firstly, the interactive mode you may know from reviewing and updating failed snapshots can now also be used to **step through failed tests** one at a time. Credit goes to first-time contributor [@NullDivision](https://github.com/NullDivision) for [implementing](https://github.com/facebook/jest/pull/10858) this feature! +Firstly, the interactive mode you may know from reviewing and updating failed snapshots can now also be used to **step through failed tests** one at a time. Credit goes to first-time contributor [@NullDivision](https://github.com/NullDivision) for [implementing](https://github.com/jestjs/jest/pull/10858) this feature! ![Interactive failed test run](/img/blog/27-interactive-failures.png) -Speaking of snapshots, one of the more exciting features we've shipped in recent years are Inline Snapshots, which [landed](https://github.com/facebook/jest/pull/6380) in a minor release of Jest 23 almost three years ago. However, they came with the restriction that projects wanting to utilize them must be using [Prettier](https://prettier.io/) to format their code, because that's what Jest would use to make sure the file it writes the snapshots into remains properly formatted. -And so for most of these years, we've had a [pull request](https://github.com/facebook/jest/pull/7792) in the pipeline to eliminate this restriction and allow using **Inline Snapshots without Prettier**. It has amassed well above a hundred comments, not even taking into account PRs split out from it and landed first, and even changed owner once after the initial submission by another first-time contributor, [@mmkal](https://github.com/mmkal) under the hilarious working title 'Uglier Inline Snapshots'. With the stellar rise of Prettier in recent times, this improvement is now maybe less needed than back in 2018, but still, we know that feeling of getting into a project that does not use Prettier, and suddenly not being able to use inline snapshots anymore. Nevermore! +Speaking of snapshots, one of the more exciting features we've shipped in recent years are Inline Snapshots, which [landed](https://github.com/jestjs/jest/pull/6380) in a minor release of Jest 23 almost three years ago. However, they came with the restriction that projects wanting to utilize them must be using [Prettier](https://prettier.io/) to format their code, because that's what Jest would use to make sure the file it writes the snapshots into remains properly formatted. +And so for most of these years, we've had a [pull request](https://github.com/jestjs/jest/pull/7792) in the pipeline to eliminate this restriction and allow using **Inline Snapshots without Prettier**. It has amassed well above a hundred comments, not even taking into account PRs split out from it and landed first, and even changed owner once after the initial submission by another first-time contributor, [@mmkal](https://github.com/mmkal) under the hilarious working title 'Uglier Inline Snapshots'. With the stellar rise of Prettier in recent times, this improvement is now maybe less needed than back in 2018, but still, we know that feeling of getting into a project that does not use Prettier, and suddenly not being able to use inline snapshots anymore. Nevermore! The main reason why it took us so long to land this was, somewhat surprisingly, an out of memory error on our build pipeline. It turns out that the dependencies we load for each test file to perform the parsing, snapshot insertion, and printing do incur a significant time and memory overhead. -So with some [tricks](https://github.com/facebook/jest/issues/9898), we've **speed up the initialization per test file** by roughly 70% compared to Jest 26. Note that you will almost certainly not see this big of a performance improvement on your project—you would need a lot of test files that each run very quickly to best notice this, and the overhead when using a [JSDOM environment](/docs/configuration#testenvironment-string) dwarfs any such improvement. +So with some [tricks](https://github.com/jestjs/jest/issues/9898), we've **speed up the initialization per test file** by roughly 70% compared to Jest 26. Note that you will almost certainly not see this big of a performance improvement on your project—you would need a lot of test files that each run very quickly to best notice this, and the overhead when using a [JSDOM environment](/docs/configuration#testenvironment-string) dwarfs any such improvement. -In other news, the [native ESM support](https://github.com/facebook/jest/issues/9430) is progressing, but some major complexities, for instance around mocking, are still ahead of us, and we continue to observe the migration to ESM as a huge ecosystem effort, where Node and a lot of crucial tools and packages all have to rely on each other to deliver an overall compelling experience. -ESM support [for plugging modules into Jest](https://github.com/facebook/jest/issues/11167) is more advanced—custom runners, reporters, watch plugins, and many other modules can already be loaded as ES modules. +In other news, the [native ESM support](https://github.com/jestjs/jest/issues/9430) is progressing, but some major complexities, for instance around mocking, are still ahead of us, and we continue to observe the migration to ESM as a huge ecosystem effort, where Node and a lot of crucial tools and packages all have to rely on each other to deliver an overall compelling experience. +ESM support [for plugging modules into Jest](https://github.com/jestjs/jest/issues/11167) is more advanced—custom runners, reporters, watch plugins, and many other modules can already be loaded as ES modules. -We've also merged [a PR](https://github.com/facebook/jest/pull/9351) to be able to deal with test files symlinked into the test directory, a feature much wanted by users of [Bazel](https://bazel.build/). +We've also merged [a PR](https://github.com/jestjs/jest/pull/9351) to be able to deal with test files symlinked into the test directory, a feature much wanted by users of [Bazel](https://bazel.build/). -[Another PR](https://github.com/facebook/jest/issues/9504) enabled [`transform`s](/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) to be asynchronous, a requirement to support transpilation through tools such as [esbuild](https://esbuild.github.io/), [Snowpack](https://www.snowpack.dev/), and [Vite](https://vitejs.dev/) effectively. +[Another PR](https://github.com/jestjs/jest/issues/9504) enabled [`transform`s](/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) to be asynchronous, a requirement to support transpilation through tools such as [esbuild](https://esbuild.github.io/), [Snowpack](https://www.snowpack.dev/), and [Vite](https://vitejs.dev/) effectively. ## Flipping defaults -Up until now, if you were using Jest in its default configuration, you were—perhaps unknowingly—running some code forked many years ago from the test runner [Jasmine 2.0](https://jasmine.github.io/2.0/introduction) that provides test framework functions such as `describe`, `it`, and `beforeEach`. In 2017, [Aaron Abramov](https://github.com/aaronabramov) [initially wrote](https://github.com/facebook/jest/pull/3668) a **replacement for the Jasmine code** called `jest-circus`, meant to improve error messages, maintainability, and extensibility. +Up until now, if you were using Jest in its default configuration, you were—perhaps unknowingly—running some code forked many years ago from the test runner [Jasmine 2.0](https://jasmine.github.io/2.0/introduction) that provides test framework functions such as `describe`, `it`, and `beforeEach`. In 2017, [Aaron Abramov](https://github.com/aaronabramov) [initially wrote](https://github.com/jestjs/jest/pull/3668) a **replacement for the Jasmine code** called `jest-circus`, meant to improve error messages, maintainability, and extensibility. After years of large-scale use at Facebook and of course in Jest itself, as well as recent adoption in `create-react-app`, we are now confident that `jest-circus` is highly compatible with `jest-jasmine2` and should work in most environments with little to no migration work. There may be minor differences in execution order and strictness, but we expect no major upgrade difficulties other than for code relying on Jasmine-specific APIs such as `jasmine.getEnv()`. If you rely extensively on such APIs, you can opt back in to the Jasmine-based test runner by [configuring](/docs/configuration#testrunner-string) `"testRunner": "jest-jasmine2"`. Running tests in a [JSDOM environment](/docs/configuration#testenvironment-string) incurs a significant performance overhead. Because this was the default behavior of Jest unless otherwise configured up until now, users who are writing Node apps, for example, may not even know they are given an expensive DOM environment that they do not even need. @@ -51,7 +51,7 @@ We introduced a few more small breaking changes to help you avoid mistakes by di - calling `done` and returning a Promise may not be combined, - a `describe` block must not return anything, -and we [made some TypeScript types stricter](https://github.com/facebook/jest/pull/10512). +and we [made some TypeScript types stricter](https://github.com/jestjs/jest/pull/10512). Modules used in the following configuration options are now transformed like the rest of your code, which may be breaking if you relied on them being loaded as-is: @@ -72,6 +72,6 @@ A lot of Jest's packages have been migrated to use ESM-style exports (although t We dropped support for Node 13—but Jest always supports the _Current_ and all _LTS_ [Node versions](https://nodejs.org/en/about/releases/), and Jest 27 continues to support Node 10, which only recently became unmaintained. -As always, the full changelog and list of breaking changes can be [viewed here](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2700). +As always, the full changelog and list of breaking changes can be [viewed here](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2700). Finally, we'd like to thank the community for once again awarding Jest a sky-high satisfaction rating of 96% in the [State of JS 2020](https://2020.stateofjs.com/en-US/technologies/testing/) survey! Stay safe everyone, and we hope you continue to enjoy using Jest in the years and versions to come! 🃏 diff --git a/website/blog/2022-04-25-jest-28.md b/website/blog/2022-04-25-jest-28.md index 9b1995e9dfb8..1cbcbc329aa8 100644 --- a/website/blog/2022-04-25-jest-28.md +++ b/website/blog/2022-04-25-jest-28.md @@ -13,7 +13,7 @@ Additionally, as announced in the [Jest 27 blog post](/blog/2021/05/25/jest-27) ## Breaking changes -The list of breaking changes is long (and can be seen fully in the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2800)), but for migration purposes, we've also written [a guide](/docs/28.x/upgrading-to-jest28) you can follow. Hopefully this makes the upgrade experience as frictionless as possible! +The list of breaking changes is long (and can be seen fully in the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2800)), but for migration purposes, we've also written [a guide](/docs/28.x/upgrading-to-jest28) you can follow. Hopefully this makes the upgrade experience as frictionless as possible! Main breaking changes likely to impact your migration are dropped support for Node 10 and 15 (but _not_ Node 12, which will be EOL in a few days) and some renamed configuration options. @@ -120,7 +120,7 @@ If you use Jest with TypeScript, either in your tests or when writing plugins su ### `expect` -When using `expect`'s own types (either directly, or via `import {expect} from '@jest/globals'`), it's now finally possible to add custom matchers. See our [example](https://github.com/facebook/jest/tree/main/examples/expect-extend) for how to do this. +When using `expect`'s own types (either directly, or via `import {expect} from '@jest/globals'`), it's now finally possible to add custom matchers. See our [example](https://github.com/jestjs/jest/tree/main/examples/expect-extend) for how to do this. ### Custom plugins diff --git a/website/blog/2022-08-25-jest-29.md b/website/blog/2022-08-25-jest-29.md index 9ab4001bc644..3c13a6567018 100644 --- a/website/blog/2022-08-25-jest-29.md +++ b/website/blog/2022-08-25-jest-29.md @@ -25,6 +25,6 @@ The only breaking changes that should be noticeable are: There are certain changes to the types exposed by Jest, but probably (hopefully!) nothing that should impede the upgrade. Please see the [upgrade guide](/docs/upgrading-to-jest29) for more details. -That's it for breaking changes! Hopefully this means the upgrade path from Jest 28 is smooth. Please see the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for other changes. +That's it for breaking changes! Hopefully this means the upgrade path from Jest 28 is smooth. Please see the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for other changes. Thanks for reading, and happy Jesting! 🃏 diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index bdd780db9fe6..14649b3574de 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -56,7 +56,7 @@ const config = { if (translation !== 'en') { return `https://crowdin.com/project/jest-v2/${translation}`; } - return `https://github.com/facebook/jest/edit/main/website/${versionDocsDirPath}/${docPath}`; + return `https://github.com/jestjs/jest/edit/main/website/${versionDocsDirPath}/${docPath}`; }, path: '../docs', sidebarPath: path.resolve(__dirname, './sidebars.json'), @@ -67,7 +67,7 @@ const config = { }, blog: { showReadingTime: true, - editUrl: 'https://github.com/facebook/jest/tree/main/website/', + editUrl: 'https://github.com/jestjs/jest/tree/main/website/', }, theme: { customCss: [ @@ -214,7 +214,7 @@ const config = { {to: 'blog', label: 'Blog', position: 'right'}, {type: 'localeDropdown', position: 'right'}, { - href: 'https://github.com/facebook/jest', + href: 'https://github.com/jestjs/jest', position: 'right', className: 'header-github-link', 'aria-label': 'GitHub repository', @@ -272,7 +272,7 @@ const config = { }, { label: 'GitHub', - href: 'https://github.com/facebook/jest', + href: 'https://github.com/jestjs/jest', }, { label: 'Twitter', diff --git a/website/src/pages/help.js b/website/src/pages/help.js index 257ef260f1d8..161037e47d51 100755 --- a/website/src/pages/help.js +++ b/website/src/pages/help.js @@ -45,7 +45,7 @@ class Help extends React.Component { {`Find out what's new with Jest. - Follow [Jest](https://twitter.com/jestjs_) on Twitter. - Subscribe to the [Jest blog](/blog/). -- Look at the [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md).`} +- Look at the [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md).`} ), title: Stay up to date, diff --git a/website/src/pages/index.js b/website/src/pages/index.js index b23871cdee72..c189524186da 100755 --- a/website/src/pages/index.js +++ b/website/src/pages/index.js @@ -43,7 +43,7 @@ function GitHubStarButton() { return (
diff --git a/website/src/pages/versions.js b/website/src/pages/versions.js index f249ca15e5ec..60c28373af81 100644 --- a/website/src/pages/versions.js +++ b/website/src/pages/versions.js @@ -36,7 +36,7 @@ export default function VersionsPage() { Documentation - + Release Notes @@ -55,7 +55,7 @@ export default function VersionsPage() { Documentation - Source Code + Source Code diff --git a/website/static/_redirects b/website/static/_redirects index 11a3b2d954d3..fc484ab059a0 100644 --- a/website/static/_redirects +++ b/website/static/_redirects @@ -3,7 +3,7 @@ # Initially used to handle the Docusaurus v1-v2 migration url changes # https://github.com/jest-website-migration/jest -# https://github.com/facebook/jest/pull/11021 +# https://github.com/jestjs/jest/pull/11021 /en/* /:splat diff --git a/website/users.json b/website/users.json index 1c4ef994e54a..e23faca38721 100644 --- a/website/users.json +++ b/website/users.json @@ -1,5 +1,5 @@ { - "editUrl": "https://github.com/facebook/jest/edit/main/website/users.json", + "editUrl": "https://github.com/jestjs/jest/edit/main/website/users.json", "users": [ { "caption": "Facebook", diff --git a/website/versioned_docs/version-25.x/Configuration.md b/website/versioned_docs/version-25.x/Configuration.md index ac955a96935d..9d85a780abf7 100644 --- a/website/versioned_docs/version-25.x/Configuration.md +++ b/website/versioned_docs/version-25.x/Configuration.md @@ -243,7 +243,7 @@ Additional options can be passed using the tuple form. For example, you may hide } ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -446,7 +446,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) object as a parameter. +This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) object as a parameter. :::info @@ -477,7 +477,7 @@ module.exports = async function () { Default: `undefined` -This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. This function gets Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) object as a parameter. +This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. This function gets Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) object as a parameter. :::info @@ -730,7 +730,7 @@ Additionally, custom reporters can be configured by passing an `options` object } ``` -Custom reporter modules must define a class that takes a [`globalConfig`](https://github.com/facebook/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) and reporter options as constructor arguments: +Custom reporter modules must define a class that takes a [`globalConfig`](https://github.com/jestjs/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) and reporter options as constructor arguments: Example reporter: @@ -765,7 +765,7 @@ class MyCustomReporter { } ``` -For the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts) +For the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts) ### `resetMocks` \[boolean] @@ -858,7 +858,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -997,7 +997,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1022,7 +1022,7 @@ test('use jsdom in this test file', () => { You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `runScript` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -1247,7 +1247,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -1265,7 +1265,7 @@ const Sequencer = require('@jest/test-sequencer').default; class CustomSequencer extends Sequencer { sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -1304,7 +1304,7 @@ Setting this value to `legacy` or `fake` enables fake timers for all tests by de Default: `{"^.+\\.[jt]sx?$": "babel-jest"}` -A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/facebook/jest/blob/main/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). +A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/jestjs/jest/blob/main/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). Examples of such compilers include: @@ -1323,7 +1323,7 @@ A transformer is only run once per file unless the file has changed. During the :::note -When adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). +When adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). ::: diff --git a/website/versioned_docs/version-25.x/ECMAScriptModules.md b/website/versioned_docs/version-25.x/ECMAScriptModules.md index 9ac5406f52f7..61f7fbbbff8a 100644 --- a/website/versioned_docs/version-25.x/ECMAScriptModules.md +++ b/website/versioned_docs/version-25.x/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -72,4 +72,4 @@ const exported = await import('./main.cjs'); // etc. ``` -Please note that we currently don't support `jest.mock` in a clean way in ESM, but that is something we intend to add proper support for in the future. Follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +Please note that we currently don't support `jest.mock` in a clean way in ESM, but that is something we intend to add proper support for in the future. Follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. diff --git a/website/versioned_docs/version-25.x/ExpectAPI.md b/website/versioned_docs/version-25.x/ExpectAPI.md index 323d257dc76c..f4432aa4d876 100644 --- a/website/versioned_docs/version-25.x/ExpectAPI.md +++ b/website/versioned_docs/version-25.x/ExpectAPI.md @@ -182,7 +182,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-25.x/JestObjectAPI.md b/website/versioned_docs/version-25.x/JestObjectAPI.md index 0590a21cbd8d..3e2067dfcddc 100644 --- a/website/versioned_docs/version-25.x/JestObjectAPI.md +++ b/website/versioned_docs/version-25.x/JestObjectAPI.md @@ -701,7 +701,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-25.x/JestPlatform.md b/website/versioned_docs/version-25.x/JestPlatform.md index 1cc478cbacc7..298f5cf64600 100644 --- a/website/versioned_docs/version-25.x/JestPlatform.md +++ b/website/versioned_docs/version-25.x/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-25.x/ManualMocks.md b/website/versioned_docs/version-25.x/ManualMocks.md index 39368f2a3a02..62e80a9b9079 100644 --- a/website/versioned_docs/version-25.x/ManualMocks.md +++ b/website/versioned_docs/version-25.x/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.genMockFromModule`](JestObjectAPI.md#jes To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-25.x/MockFunctionAPI.md b/website/versioned_docs/version-25.x/MockFunctionAPI.md index 3cbc6e53f6ad..9d591d222426 100644 --- a/website/versioned_docs/version-25.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-25.x/MockFunctionAPI.md @@ -356,7 +356,7 @@ If you are using [Create React App](https://create-react-app.dev) then the [Type Otherwise, please see our [Getting Started](GettingStarted.md#using-typescript) guide for to get setup with TypeScript. -You can see an example of using Jest with TypeScript in our [GitHub repository](https://github.com/facebook/jest/tree/main/examples/typescript). +You can see an example of using Jest with TypeScript in our [GitHub repository](https://github.com/jestjs/jest/tree/main/examples/typescript). ### `jest.MockedFunction` diff --git a/website/versioned_docs/version-25.x/MoreResources.md b/website/versioned_docs/version-25.x/MoreResources.md index 500482e69388..c55840f82415 100644 --- a/website/versioned_docs/version-25.x/MoreResources.md +++ b/website/versioned_docs/version-25.x/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-25.x/Puppeteer.md b/website/versioned_docs/version-25.x/Puppeteer.md index c1aafd6ba637..a05edd1fc702 100644 --- a/website/versioned_docs/version-25.x/Puppeteer.md +++ b/website/versioned_docs/version-25.x/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-25.x/SnapshotTesting.md b/website/versioned_docs/version-25.x/SnapshotTesting.md index 1dabee33f66a..952ae6a508c2 100644 --- a/website/versioned_docs/version-25.x/SnapshotTesting.md +++ b/website/versioned_docs/version-25.x/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import React from 'react'; @@ -24,7 +24,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -39,7 +39,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -85,7 +85,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -245,7 +245,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -305,7 +305,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-25.x/TimerMocks.md b/website/versioned_docs/version-25.x/TimerMocks.md index d7d4e67c7b12..58794c6a190a 100644 --- a/website/versioned_docs/version-25.x/TimerMocks.md +++ b/website/versioned_docs/version-25.x/TimerMocks.md @@ -182,4 +182,4 @@ it('calls the callback after 1 second via advanceTimersByTime', () => { Lastly, it may occasionally be useful in some tests to be able to clear all of the pending timers. For this, we have `jest.clearAllTimers()`. -The code for this example is available at [examples/timer](https://github.com/facebook/jest/tree/main/examples/timer). +The code for this example is available at [examples/timer](https://github.com/jestjs/jest/tree/main/examples/timer). diff --git a/website/versioned_docs/version-25.x/Troubleshooting.md b/website/versioned_docs/version-25.x/Troubleshooting.md index 37a217b011a2..5efe7e9efd24 100644 --- a/website/versioned_docs/version-25.x/Troubleshooting.md +++ b/website/versioned_docs/version-25.x/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-25.x/TutorialAsync.md b/website/versioned_docs/version-25.x/TutorialAsync.md index f9bbe7f6713f..d7f712fd9398 100644 --- a/website/versioned_docs/version-25.x/TutorialAsync.md +++ b/website/versioned_docs/version-25.x/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-25.x/TutorialReact.md b/website/versioned_docs/version-25.x/TutorialReact.md index 4f39f70189c1..65cce15c0bbf 100644 --- a/website/versioned_docs/version-25.x/TutorialReact.md +++ b/website/versioned_docs/version-25.x/TutorialReact.md @@ -162,7 +162,7 @@ exports[`Link changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16 @@ -251,7 +251,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-25.x/TutorialReactNative.md b/website/versioned_docs/version-25.x/TutorialReactNative.md index 89da13d6e59c..8804c38a1b20 100644 --- a/website/versioned_docs/version-25.x/TutorialReactNative.md +++ b/website/versioned_docs/version-25.x/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-25.x/TutorialjQuery.md b/website/versioned_docs/version-25.x/TutorialjQuery.md index d6f32d3c74f6..e2bc3b3969cb 100644 --- a/website/versioned_docs/version-25.x/TutorialjQuery.md +++ b/website/versioned_docs/version-25.x/TutorialjQuery.md @@ -63,4 +63,4 @@ The function being tested adds an event listener on the `#button` DOM element, s We are mocking `fetchCurrentUser.js` so that our test doesn't make a real network request but instead resolves to mock data locally. This ensures that our test can complete in milliseconds rather than seconds and guarantees a fast unit test iteration speed. -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-25.x/WatchPlugins.md b/website/versioned_docs/version-25.x/WatchPlugins.md index f9c42462c9b9..13b53cd301c6 100644 --- a/website/versioned_docs/version-25.x/WatchPlugins.md +++ b/website/versioned_docs/version-25.x/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v25.5.4/packages/jest-types/src/Config.ts#L234-L300): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-26.x/Configuration.md b/website/versioned_docs/version-26.x/Configuration.md index a3e5c2a5b331..3859d39f9fe3 100644 --- a/website/versioned_docs/version-26.x/Configuration.md +++ b/website/versioned_docs/version-26.x/Configuration.md @@ -260,7 +260,7 @@ Additional options can be passed using the tuple form. For example, you may hide } ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -463,7 +463,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) object as a parameter. +This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) object as a parameter. :::info @@ -494,7 +494,7 @@ module.exports = async function () { Default: `undefined` -This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. This function gets Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) object as a parameter. +This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. This function gets Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) object as a parameter. :::info @@ -769,7 +769,7 @@ Additionally, custom reporters can be configured by passing an `options` object } ``` -Custom reporter modules must define a class that takes a [`globalConfig`](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) and reporter options as constructor arguments: +Custom reporter modules must define a class that takes a [`globalConfig`](https://github.com/jestjs/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) and reporter options as constructor arguments: Example reporter: @@ -804,7 +804,7 @@ class MyCustomReporter { } ``` -For the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts) +For the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts) ### `resetMocks` \[boolean] @@ -944,7 +944,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1083,7 +1083,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1108,7 +1108,7 @@ test('use jsdom in this test file', () => { You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `runScript` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -1333,7 +1333,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -1351,7 +1351,7 @@ const Sequencer = require('@jest/test-sequencer').default; class CustomSequencer extends Sequencer { sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -1392,7 +1392,7 @@ If the value is `modern`, [`@sinonjs/fake-timers`](https://github.com/sinonjs/fa Default: `{"\\.[jt]sx?$": "babel-jest"}` -A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/facebook/jest/blob/main/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). +A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/jestjs/jest/blob/main/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). Examples of such compilers include: @@ -1411,7 +1411,7 @@ A transformer is only run once per file unless the file has changed. During the :::note -When adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). +When adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). ::: diff --git a/website/versioned_docs/version-26.x/ECMAScriptModules.md b/website/versioned_docs/version-26.x/ECMAScriptModules.md index 9ac5406f52f7..61f7fbbbff8a 100644 --- a/website/versioned_docs/version-26.x/ECMAScriptModules.md +++ b/website/versioned_docs/version-26.x/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -72,4 +72,4 @@ const exported = await import('./main.cjs'); // etc. ``` -Please note that we currently don't support `jest.mock` in a clean way in ESM, but that is something we intend to add proper support for in the future. Follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +Please note that we currently don't support `jest.mock` in a clean way in ESM, but that is something we intend to add proper support for in the future. Follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. diff --git a/website/versioned_docs/version-26.x/ExpectAPI.md b/website/versioned_docs/version-26.x/ExpectAPI.md index 323d257dc76c..f4432aa4d876 100644 --- a/website/versioned_docs/version-26.x/ExpectAPI.md +++ b/website/versioned_docs/version-26.x/ExpectAPI.md @@ -182,7 +182,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-26.x/GlobalAPI.md b/website/versioned_docs/version-26.x/GlobalAPI.md index 7438f00993b8..c834e5fffc53 100644 --- a/website/versioned_docs/version-26.x/GlobalAPI.md +++ b/website/versioned_docs/version-26.x/GlobalAPI.md @@ -477,7 +477,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: diff --git a/website/versioned_docs/version-26.x/JestObjectAPI.md b/website/versioned_docs/version-26.x/JestObjectAPI.md index bce3a5dddf6a..17a2206ff200 100644 --- a/website/versioned_docs/version-26.x/JestObjectAPI.md +++ b/website/versioned_docs/version-26.x/JestObjectAPI.md @@ -735,7 +735,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-26.x/JestPlatform.md b/website/versioned_docs/version-26.x/JestPlatform.md index 429b1172c8bb..208976e52f5b 100644 --- a/website/versioned_docs/version-26.x/JestPlatform.md +++ b/website/versioned_docs/version-26.x/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-26.x/ManualMocks.md b/website/versioned_docs/version-26.x/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-26.x/ManualMocks.md +++ b/website/versioned_docs/version-26.x/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-26.x/MockFunctionAPI.md b/website/versioned_docs/version-26.x/MockFunctionAPI.md index 3cbc6e53f6ad..9d591d222426 100644 --- a/website/versioned_docs/version-26.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-26.x/MockFunctionAPI.md @@ -356,7 +356,7 @@ If you are using [Create React App](https://create-react-app.dev) then the [Type Otherwise, please see our [Getting Started](GettingStarted.md#using-typescript) guide for to get setup with TypeScript. -You can see an example of using Jest with TypeScript in our [GitHub repository](https://github.com/facebook/jest/tree/main/examples/typescript). +You can see an example of using Jest with TypeScript in our [GitHub repository](https://github.com/jestjs/jest/tree/main/examples/typescript). ### `jest.MockedFunction` diff --git a/website/versioned_docs/version-26.x/MoreResources.md b/website/versioned_docs/version-26.x/MoreResources.md index 500482e69388..c55840f82415 100644 --- a/website/versioned_docs/version-26.x/MoreResources.md +++ b/website/versioned_docs/version-26.x/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-26.x/Puppeteer.md b/website/versioned_docs/version-26.x/Puppeteer.md index c1aafd6ba637..a05edd1fc702 100644 --- a/website/versioned_docs/version-26.x/Puppeteer.md +++ b/website/versioned_docs/version-26.x/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-26.x/SnapshotTesting.md b/website/versioned_docs/version-26.x/SnapshotTesting.md index 1dabee33f66a..952ae6a508c2 100644 --- a/website/versioned_docs/version-26.x/SnapshotTesting.md +++ b/website/versioned_docs/version-26.x/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import React from 'react'; @@ -24,7 +24,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -39,7 +39,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -85,7 +85,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -245,7 +245,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -305,7 +305,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-26.x/TimerMocks.md b/website/versioned_docs/version-26.x/TimerMocks.md index 81e9f5e120a8..8ed1ce179a28 100644 --- a/website/versioned_docs/version-26.x/TimerMocks.md +++ b/website/versioned_docs/version-26.x/TimerMocks.md @@ -166,4 +166,4 @@ it('calls the callback after 1 second via advanceTimersByTime', () => { Lastly, it may occasionally be useful in some tests to be able to clear all of the pending timers. For this, we have `jest.clearAllTimers()`. -The code for this example is available at [examples/timer](https://github.com/facebook/jest/tree/main/examples/timer). +The code for this example is available at [examples/timer](https://github.com/jestjs/jest/tree/main/examples/timer). diff --git a/website/versioned_docs/version-26.x/Troubleshooting.md b/website/versioned_docs/version-26.x/Troubleshooting.md index 37a217b011a2..5efe7e9efd24 100644 --- a/website/versioned_docs/version-26.x/Troubleshooting.md +++ b/website/versioned_docs/version-26.x/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-26.x/TutorialAsync.md b/website/versioned_docs/version-26.x/TutorialAsync.md index f9bbe7f6713f..d7f712fd9398 100644 --- a/website/versioned_docs/version-26.x/TutorialAsync.md +++ b/website/versioned_docs/version-26.x/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-26.x/TutorialReact.md b/website/versioned_docs/version-26.x/TutorialReact.md index 4f39f70189c1..65cce15c0bbf 100644 --- a/website/versioned_docs/version-26.x/TutorialReact.md +++ b/website/versioned_docs/version-26.x/TutorialReact.md @@ -162,7 +162,7 @@ exports[`Link changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16 @@ -251,7 +251,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-26.x/TutorialReactNative.md b/website/versioned_docs/version-26.x/TutorialReactNative.md index 89da13d6e59c..8804c38a1b20 100644 --- a/website/versioned_docs/version-26.x/TutorialReactNative.md +++ b/website/versioned_docs/version-26.x/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-26.x/TutorialjQuery.md b/website/versioned_docs/version-26.x/TutorialjQuery.md index d6f32d3c74f6..e2bc3b3969cb 100644 --- a/website/versioned_docs/version-26.x/TutorialjQuery.md +++ b/website/versioned_docs/version-26.x/TutorialjQuery.md @@ -63,4 +63,4 @@ The function being tested adds an event listener on the `#button` DOM element, s We are mocking `fetchCurrentUser.js` so that our test doesn't make a real network request but instead resolves to mock data locally. This ensures that our test can complete in milliseconds rather than seconds and guarantees a fast unit test iteration speed. -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-26.x/WatchPlugins.md b/website/versioned_docs/version-26.x/WatchPlugins.md index fa54ce13ff0c..892017c9ab73 100644 --- a/website/versioned_docs/version-26.x/WatchPlugins.md +++ b/website/versioned_docs/version-26.x/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L255-L321): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-27.x/CodeTransformation.md b/website/versioned_docs/version-27.x/CodeTransformation.md index bf97210d3284..28f5ae772231 100644 --- a/website/versioned_docs/version-27.x/CodeTransformation.md +++ b/website/versioned_docs/version-27.x/CodeTransformation.md @@ -128,7 +128,7 @@ type TransformedSource = | {code: string; map?: RawSourceMap | string | null} | string; -// Config.ProjectConfig can be seen in code [here](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L323) +// Config.ProjectConfig can be seen in code [here](https://github.com/jestjs/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L323) // RawSourceMap comes from [`source-map`](https://github.com/mozilla/source-map/blob/0.6.1/source-map.d.ts#L6-L12) ``` diff --git a/website/versioned_docs/version-27.x/Configuration.md b/website/versioned_docs/version-27.x/Configuration.md index c9d0653cc23d..7c14c051dc67 100644 --- a/website/versioned_docs/version-27.x/Configuration.md +++ b/website/versioned_docs/version-27.x/Configuration.md @@ -260,7 +260,7 @@ Additional options can be passed using the tuple form. For example, you may hide } ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -484,7 +484,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) object as a parameter. +This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) object as a parameter. :::info @@ -515,7 +515,7 @@ module.exports = async function () { Default: `undefined` -This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. This function gets Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) object as a parameter. +This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. This function gets Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) object as a parameter. :::info @@ -800,7 +800,7 @@ Additionally, custom reporters can be configured by passing an `options` object } ``` -Custom reporter modules must define a class that takes a [`globalConfig`](https://github.com/facebook/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) and reporter options as constructor arguments: +Custom reporter modules must define a class that takes a [`globalConfig`](https://github.com/jestjs/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) and reporter options as constructor arguments: Example reporter: @@ -835,7 +835,7 @@ class MyCustomReporter { } ``` -For the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts) +For the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts) ### `resetMocks` \[boolean] @@ -979,7 +979,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1153,7 +1153,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1178,7 +1178,7 @@ test('use jsdom in this test file', () => { You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -1403,7 +1403,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -1421,7 +1421,7 @@ const Sequencer = require('@jest/test-sequencer').default; class CustomSequencer extends Sequencer { sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -1462,7 +1462,7 @@ If the value is `legacy`, the old implementation will be used as implementation Default: `{"\\.[jt]sx?$": "babel-jest"}` -A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/facebook/jest/blob/main/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). +A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/jestjs/jest/blob/main/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). Examples of such compilers include: @@ -1480,7 +1480,7 @@ A transformer is only run once per file unless the file has changed. During the :::note -When adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). +When adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). ::: diff --git a/website/versioned_docs/version-27.x/ECMAScriptModules.md b/website/versioned_docs/version-27.x/ECMAScriptModules.md index 118a2140bcff..896317f63565 100644 --- a/website/versioned_docs/version-27.x/ECMAScriptModules.md +++ b/website/versioned_docs/version-27.x/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -41,7 +41,7 @@ jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-27.x/ExpectAPI.md b/website/versioned_docs/version-27.x/ExpectAPI.md index da567b7ac4cb..ede9cad336f6 100644 --- a/website/versioned_docs/version-27.x/ExpectAPI.md +++ b/website/versioned_docs/version-27.x/ExpectAPI.md @@ -182,7 +182,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-27.x/GlobalAPI.md b/website/versioned_docs/version-27.x/GlobalAPI.md index bb5d1c4311a3..8fffd57e026a 100644 --- a/website/versioned_docs/version-27.x/GlobalAPI.md +++ b/website/versioned_docs/version-27.x/GlobalAPI.md @@ -501,7 +501,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: diff --git a/website/versioned_docs/version-27.x/JestObjectAPI.md b/website/versioned_docs/version-27.x/JestObjectAPI.md index 25a665116f18..f7873daaae82 100644 --- a/website/versioned_docs/version-27.x/JestObjectAPI.md +++ b/website/versioned_docs/version-27.x/JestObjectAPI.md @@ -781,7 +781,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-27.x/JestPlatform.md b/website/versioned_docs/version-27.x/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-27.x/JestPlatform.md +++ b/website/versioned_docs/version-27.x/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-27.x/ManualMocks.md b/website/versioned_docs/version-27.x/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-27.x/ManualMocks.md +++ b/website/versioned_docs/version-27.x/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-27.x/MockFunctionAPI.md b/website/versioned_docs/version-27.x/MockFunctionAPI.md index a5eb6f45a7de..c5d70b042f6e 100644 --- a/website/versioned_docs/version-27.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-27.x/MockFunctionAPI.md @@ -366,7 +366,7 @@ If you are using [Create React App](https://create-react-app.dev) then the [Type Otherwise, please see our [Getting Started](GettingStarted.md#using-typescript) guide for to get setup with TypeScript. -You can see an example of using Jest with TypeScript in our [GitHub repository](https://github.com/facebook/jest/tree/main/examples/typescript). +You can see an example of using Jest with TypeScript in our [GitHub repository](https://github.com/jestjs/jest/tree/main/examples/typescript). ### `jest.MockedFunction` diff --git a/website/versioned_docs/version-27.x/MoreResources.md b/website/versioned_docs/version-27.x/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-27.x/MoreResources.md +++ b/website/versioned_docs/version-27.x/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-27.x/Puppeteer.md b/website/versioned_docs/version-27.x/Puppeteer.md index 7d4b6576c86b..76493ab6ada5 100644 --- a/website/versioned_docs/version-27.x/Puppeteer.md +++ b/website/versioned_docs/version-27.x/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-27.x/SnapshotTesting.md b/website/versioned_docs/version-27.x/SnapshotTesting.md index f7cad46f049f..4ca5ba308a2a 100644 --- a/website/versioned_docs/version-27.x/SnapshotTesting.md +++ b/website/versioned_docs/version-27.x/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import React from 'react'; @@ -24,7 +24,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -39,7 +39,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -85,7 +85,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -237,7 +237,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -297,7 +297,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-27.x/TimerMocks.md b/website/versioned_docs/version-27.x/TimerMocks.md index 6f811abee6b4..6a8d1018dd01 100644 --- a/website/versioned_docs/version-27.x/TimerMocks.md +++ b/website/versioned_docs/version-27.x/TimerMocks.md @@ -182,4 +182,4 @@ it('calls the callback after 1 second via advanceTimersByTime', () => { Lastly, it may occasionally be useful in some tests to be able to clear all of the pending timers. For this, we have `jest.clearAllTimers()`. -The code for this example is available at [examples/timer](https://github.com/facebook/jest/tree/main/examples/timer). +The code for this example is available at [examples/timer](https://github.com/jestjs/jest/tree/main/examples/timer). diff --git a/website/versioned_docs/version-27.x/Troubleshooting.md b/website/versioned_docs/version-27.x/Troubleshooting.md index 37a217b011a2..5efe7e9efd24 100644 --- a/website/versioned_docs/version-27.x/Troubleshooting.md +++ b/website/versioned_docs/version-27.x/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-27.x/TutorialAsync.md b/website/versioned_docs/version-27.x/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-27.x/TutorialAsync.md +++ b/website/versioned_docs/version-27.x/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-27.x/TutorialReact.md b/website/versioned_docs/version-27.x/TutorialReact.md index 7dc4e17818a8..b19e61d49b75 100644 --- a/website/versioned_docs/version-27.x/TutorialReact.md +++ b/website/versioned_docs/version-27.x/TutorialReact.md @@ -162,7 +162,7 @@ exports[`Link changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16 @@ -251,7 +251,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-27.x/TutorialReactNative.md b/website/versioned_docs/version-27.x/TutorialReactNative.md index c5a31d55a5bb..15b4537243f6 100644 --- a/website/versioned_docs/version-27.x/TutorialReactNative.md +++ b/website/versioned_docs/version-27.x/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-27.x/TutorialjQuery.md b/website/versioned_docs/version-27.x/TutorialjQuery.md index d6f32d3c74f6..e2bc3b3969cb 100644 --- a/website/versioned_docs/version-27.x/TutorialjQuery.md +++ b/website/versioned_docs/version-27.x/TutorialjQuery.md @@ -63,4 +63,4 @@ The function being tested adds an event listener on the `#button` DOM element, s We are mocking `fetchCurrentUser.js` so that our test doesn't make a real network request but instead resolves to mock data locally. This ensures that our test can complete in milliseconds rather than seconds and guarantees a fast unit test iteration speed. -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-27.x/WatchPlugins.md b/website/versioned_docs/version-27.x/WatchPlugins.md index d295bb248d68..cedcfdf5f0bf 100644 --- a/website/versioned_docs/version-27.x/WatchPlugins.md +++ b/website/versioned_docs/version-27.x/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v27.5.1/packages/jest-types/src/Config.ts#L288-L350): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-28.x/CodeTransformation.md b/website/versioned_docs/version-28.x/CodeTransformation.md index ab59f9cc03a1..582923eeb3c0 100644 --- a/website/versioned_docs/version-28.x/CodeTransformation.md +++ b/website/versioned_docs/version-28.x/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-28.x/Configuration.md b/website/versioned_docs/version-28.x/Configuration.md index c09915f6b902..ed5e5936cf8a 100644 --- a/website/versioned_docs/version-28.x/Configuration.md +++ b/website/versioned_docs/version-28.x/Configuration.md @@ -260,7 +260,7 @@ Additional options can be passed using the tuple form. For example, you may hide } ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -565,7 +565,7 @@ Note that, if you specify a global reference value (like an object or array) her Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L424-L480). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L424-L480). :::info @@ -600,7 +600,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L424-L480). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L424-L480). :::info @@ -910,7 +910,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1077,7 +1077,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1286,7 +1286,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1309,9 +1309,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L424-L480) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L424-L480) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -1564,7 +1564,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -1606,7 +1606,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -1635,7 +1635,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. diff --git a/website/versioned_docs/version-28.x/ECMAScriptModules.md b/website/versioned_docs/version-28.x/ECMAScriptModules.md index 38e00b7ab514..75cbc17709ee 100644 --- a/website/versioned_docs/version-28.x/ECMAScriptModules.md +++ b/website/versioned_docs/version-28.x/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -46,7 +46,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-28.x/ExpectAPI.md b/website/versioned_docs/version-28.x/ExpectAPI.md index da567b7ac4cb..ede9cad336f6 100644 --- a/website/versioned_docs/version-28.x/ExpectAPI.md +++ b/website/versioned_docs/version-28.x/ExpectAPI.md @@ -182,7 +182,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-28.x/GlobalAPI.md b/website/versioned_docs/version-28.x/GlobalAPI.md index 22384d8a558e..c0a8a4147f20 100644 --- a/website/versioned_docs/version-28.x/GlobalAPI.md +++ b/website/versioned_docs/version-28.x/GlobalAPI.md @@ -501,7 +501,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -747,7 +747,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -779,7 +779,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -791,7 +791,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-28.x/JestObjectAPI.md b/website/versioned_docs/version-28.x/JestObjectAPI.md index 2d40fe820a86..f07b6fc7a740 100644 --- a/website/versioned_docs/version-28.x/JestObjectAPI.md +++ b/website/versioned_docs/version-28.x/JestObjectAPI.md @@ -891,7 +891,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-28.x/JestPlatform.md b/website/versioned_docs/version-28.x/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-28.x/JestPlatform.md +++ b/website/versioned_docs/version-28.x/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-28.x/ManualMocks.md b/website/versioned_docs/version-28.x/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-28.x/ManualMocks.md +++ b/website/versioned_docs/version-28.x/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-28.x/MoreResources.md b/website/versioned_docs/version-28.x/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-28.x/MoreResources.md +++ b/website/versioned_docs/version-28.x/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-28.x/Puppeteer.md b/website/versioned_docs/version-28.x/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-28.x/Puppeteer.md +++ b/website/versioned_docs/version-28.x/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-28.x/SnapshotTesting.md b/website/versioned_docs/version-28.x/SnapshotTesting.md index dfbe33c25995..7888ad1004e7 100644 --- a/website/versioned_docs/version-28.x/SnapshotTesting.md +++ b/website/versioned_docs/version-28.x/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-28.x/Troubleshooting.md b/website/versioned_docs/version-28.x/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-28.x/Troubleshooting.md +++ b/website/versioned_docs/version-28.x/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-28.x/TutorialAsync.md b/website/versioned_docs/version-28.x/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-28.x/TutorialAsync.md +++ b/website/versioned_docs/version-28.x/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-28.x/TutorialReact.md b/website/versioned_docs/version-28.x/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-28.x/TutorialReact.md +++ b/website/versioned_docs/version-28.x/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-28.x/TutorialReactNative.md b/website/versioned_docs/version-28.x/TutorialReactNative.md index c5a31d55a5bb..15b4537243f6 100644 --- a/website/versioned_docs/version-28.x/TutorialReactNative.md +++ b/website/versioned_docs/version-28.x/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-28.x/TutorialjQuery.md b/website/versioned_docs/version-28.x/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-28.x/TutorialjQuery.md +++ b/website/versioned_docs/version-28.x/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-28.x/UpgradingToJest28.md b/website/versioned_docs/version-28.x/UpgradingToJest28.md index e529cab06118..6a9de0206775 100644 --- a/website/versioned_docs/version-28.x/UpgradingToJest28.md +++ b/website/versioned_docs/version-28.x/UpgradingToJest28.md @@ -7,7 +7,7 @@ Upgrading Jest from v27 to v28? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2800) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2800) for the full list of changes. ::: @@ -129,7 +129,7 @@ If legacy fake timers are enabled in Jest config file, but you would like to dis ### Custom Environment -The constructor of [test environment](Configuration.md#testenvironment-string) class now receives an object with Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and `projectConfig` as its first argument. The second argument is now mandatory. +The constructor of [test environment](Configuration.md#testenvironment-string) class now receives an object with Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422) and `projectConfig` as its first argument. The second argument is now mandatory. ```diff class CustomEnvironment extends NodeEnvironment { diff --git a/website/versioned_docs/version-28.x/WatchPlugins.md b/website/versioned_docs/version-28.x/WatchPlugins.md index eeeab1d2c8b7..680e6af59bb2 100644 --- a/website/versioned_docs/version-28.x/WatchPlugins.md +++ b/website/versioned_docs/version-28.x/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v28.1.3/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.0/CodeTransformation.md b/website/versioned_docs/version-29.0/CodeTransformation.md index 6a7bdebd4799..1bf6dc48ba6f 100644 --- a/website/versioned_docs/version-29.0/CodeTransformation.md +++ b/website/versioned_docs/version-29.0/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.0/Configuration.md b/website/versioned_docs/version-29.0/Configuration.md index 2cc113521b12..83acd74cd3bc 100644 --- a/website/versioned_docs/version-29.0/Configuration.md +++ b/website/versioned_docs/version-29.0/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L421-L478). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L421-L478). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L421-L478). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L421-L478). :::info @@ -1330,7 +1330,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1512,7 +1512,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1760,7 +1760,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1783,9 +1783,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L421-L478) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L421-L478) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2072,7 +2072,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2112,7 +2112,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2154,7 +2154,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2369,7 +2369,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2387,7 +2387,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.0/ECMAScriptModules.md b/website/versioned_docs/version-29.0/ECMAScriptModules.md index 38e00b7ab514..75cbc17709ee 100644 --- a/website/versioned_docs/version-29.0/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.0/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -46,7 +46,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.0/ExpectAPI.md b/website/versioned_docs/version-29.0/ExpectAPI.md index f235097bda20..caba37d13841 100644 --- a/website/versioned_docs/version-29.0/ExpectAPI.md +++ b/website/versioned_docs/version-29.0/ExpectAPI.md @@ -281,7 +281,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.0/GlobalAPI.md b/website/versioned_docs/version-29.0/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.0/GlobalAPI.md +++ b/website/versioned_docs/version-29.0/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.0/JestObjectAPI.md b/website/versioned_docs/version-29.0/JestObjectAPI.md index 95648c18207a..277ec8a8e928 100644 --- a/website/versioned_docs/version-29.0/JestObjectAPI.md +++ b/website/versioned_docs/version-29.0/JestObjectAPI.md @@ -869,7 +869,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.0/JestPlatform.md b/website/versioned_docs/version-29.0/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.0/JestPlatform.md +++ b/website/versioned_docs/version-29.0/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.0/ManualMocks.md b/website/versioned_docs/version-29.0/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.0/ManualMocks.md +++ b/website/versioned_docs/version-29.0/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.0/MoreResources.md b/website/versioned_docs/version-29.0/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.0/MoreResources.md +++ b/website/versioned_docs/version-29.0/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.0/Puppeteer.md b/website/versioned_docs/version-29.0/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.0/Puppeteer.md +++ b/website/versioned_docs/version-29.0/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.0/SnapshotTesting.md b/website/versioned_docs/version-29.0/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.0/SnapshotTesting.md +++ b/website/versioned_docs/version-29.0/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.0/Troubleshooting.md b/website/versioned_docs/version-29.0/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.0/Troubleshooting.md +++ b/website/versioned_docs/version-29.0/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.0/TutorialAsync.md b/website/versioned_docs/version-29.0/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.0/TutorialAsync.md +++ b/website/versioned_docs/version-29.0/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.0/TutorialReact.md b/website/versioned_docs/version-29.0/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-29.0/TutorialReact.md +++ b/website/versioned_docs/version-29.0/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-29.0/TutorialReactNative.md b/website/versioned_docs/version-29.0/TutorialReactNative.md index c5a31d55a5bb..15b4537243f6 100644 --- a/website/versioned_docs/version-29.0/TutorialReactNative.md +++ b/website/versioned_docs/version-29.0/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.0/TutorialjQuery.md b/website/versioned_docs/version-29.0/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.0/TutorialjQuery.md +++ b/website/versioned_docs/version-29.0/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.0/UpgradingToJest29.md b/website/versioned_docs/version-29.0/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.0/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.0/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.0/WatchPlugins.md b/website/versioned_docs/version-29.0/WatchPlugins.md index fa48325d7255..652466a771c9 100644 --- a/website/versioned_docs/version-29.0/WatchPlugins.md +++ b/website/versioned_docs/version-29.0/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.0.3/packages/jest-types/src/Config.ts#L357-L419): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.1/CodeTransformation.md b/website/versioned_docs/version-29.1/CodeTransformation.md index f9c73b5420ee..7c3bafa48fde 100644 --- a/website/versioned_docs/version-29.1/CodeTransformation.md +++ b/website/versioned_docs/version-29.1/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.1/Configuration.md b/website/versioned_docs/version-29.1/Configuration.md index 1526b7c0de80..2124edfce7f1 100644 --- a/website/versioned_docs/version-29.1/Configuration.md +++ b/website/versioned_docs/version-29.1/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L421-L478). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L421-L478). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L421-L478). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L421-L478). :::info @@ -1330,7 +1330,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1512,7 +1512,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1760,7 +1760,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1783,9 +1783,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L421-L478) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L421-L478) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2072,7 +2072,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2112,7 +2112,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2154,7 +2154,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2369,7 +2369,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2387,7 +2387,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.1/ECMAScriptModules.md b/website/versioned_docs/version-29.1/ECMAScriptModules.md index 38e00b7ab514..75cbc17709ee 100644 --- a/website/versioned_docs/version-29.1/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.1/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -46,7 +46,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.1/ExpectAPI.md b/website/versioned_docs/version-29.1/ExpectAPI.md index f235097bda20..caba37d13841 100644 --- a/website/versioned_docs/version-29.1/ExpectAPI.md +++ b/website/versioned_docs/version-29.1/ExpectAPI.md @@ -281,7 +281,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.1/GlobalAPI.md b/website/versioned_docs/version-29.1/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.1/GlobalAPI.md +++ b/website/versioned_docs/version-29.1/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.1/JestObjectAPI.md b/website/versioned_docs/version-29.1/JestObjectAPI.md index 116b18bf74a4..e0fb7fd94676 100644 --- a/website/versioned_docs/version-29.1/JestObjectAPI.md +++ b/website/versioned_docs/version-29.1/JestObjectAPI.md @@ -946,7 +946,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.1/JestPlatform.md b/website/versioned_docs/version-29.1/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.1/JestPlatform.md +++ b/website/versioned_docs/version-29.1/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.1/ManualMocks.md b/website/versioned_docs/version-29.1/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.1/ManualMocks.md +++ b/website/versioned_docs/version-29.1/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.1/MoreResources.md b/website/versioned_docs/version-29.1/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.1/MoreResources.md +++ b/website/versioned_docs/version-29.1/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.1/Puppeteer.md b/website/versioned_docs/version-29.1/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.1/Puppeteer.md +++ b/website/versioned_docs/version-29.1/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.1/SnapshotTesting.md b/website/versioned_docs/version-29.1/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.1/SnapshotTesting.md +++ b/website/versioned_docs/version-29.1/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.1/Troubleshooting.md b/website/versioned_docs/version-29.1/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.1/Troubleshooting.md +++ b/website/versioned_docs/version-29.1/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.1/TutorialAsync.md b/website/versioned_docs/version-29.1/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.1/TutorialAsync.md +++ b/website/versioned_docs/version-29.1/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.1/TutorialReact.md b/website/versioned_docs/version-29.1/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-29.1/TutorialReact.md +++ b/website/versioned_docs/version-29.1/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-29.1/TutorialReactNative.md b/website/versioned_docs/version-29.1/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/website/versioned_docs/version-29.1/TutorialReactNative.md +++ b/website/versioned_docs/version-29.1/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.1/TutorialjQuery.md b/website/versioned_docs/version-29.1/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.1/TutorialjQuery.md +++ b/website/versioned_docs/version-29.1/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.1/UpgradingToJest29.md b/website/versioned_docs/version-29.1/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.1/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.1/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.1/WatchPlugins.md b/website/versioned_docs/version-29.1/WatchPlugins.md index 9790383217f3..add83cd17afb 100644 --- a/website/versioned_docs/version-29.1/WatchPlugins.md +++ b/website/versioned_docs/version-29.1/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.1.2/packages/jest-types/src/Config.ts#L357-L419): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.2/CodeTransformation.md b/website/versioned_docs/version-29.2/CodeTransformation.md index 608da10eb418..c961f2b1d823 100644 --- a/website/versioned_docs/version-29.2/CodeTransformation.md +++ b/website/versioned_docs/version-29.2/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.2/Configuration.md b/website/versioned_docs/version-29.2/Configuration.md index 552ca34a3e93..5d465a64f50a 100644 --- a/website/versioned_docs/version-29.2/Configuration.md +++ b/website/versioned_docs/version-29.2/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -1330,7 +1330,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1766,7 +1766,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1789,9 +1789,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2078,7 +2078,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2118,7 +2118,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2160,7 +2160,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2375,7 +2375,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2393,7 +2393,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.2/ECMAScriptModules.md b/website/versioned_docs/version-29.2/ECMAScriptModules.md index 38e00b7ab514..75cbc17709ee 100644 --- a/website/versioned_docs/version-29.2/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.2/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -46,7 +46,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.2/ExpectAPI.md b/website/versioned_docs/version-29.2/ExpectAPI.md index f235097bda20..caba37d13841 100644 --- a/website/versioned_docs/version-29.2/ExpectAPI.md +++ b/website/versioned_docs/version-29.2/ExpectAPI.md @@ -281,7 +281,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.2/GlobalAPI.md b/website/versioned_docs/version-29.2/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.2/GlobalAPI.md +++ b/website/versioned_docs/version-29.2/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.2/JestObjectAPI.md b/website/versioned_docs/version-29.2/JestObjectAPI.md index d5f1ef088641..aae2be24dfb5 100644 --- a/website/versioned_docs/version-29.2/JestObjectAPI.md +++ b/website/versioned_docs/version-29.2/JestObjectAPI.md @@ -956,7 +956,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.2/JestPlatform.md b/website/versioned_docs/version-29.2/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.2/JestPlatform.md +++ b/website/versioned_docs/version-29.2/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.2/ManualMocks.md b/website/versioned_docs/version-29.2/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.2/ManualMocks.md +++ b/website/versioned_docs/version-29.2/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.2/MoreResources.md b/website/versioned_docs/version-29.2/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.2/MoreResources.md +++ b/website/versioned_docs/version-29.2/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.2/Puppeteer.md b/website/versioned_docs/version-29.2/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.2/Puppeteer.md +++ b/website/versioned_docs/version-29.2/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.2/SnapshotTesting.md b/website/versioned_docs/version-29.2/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.2/SnapshotTesting.md +++ b/website/versioned_docs/version-29.2/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.2/Troubleshooting.md b/website/versioned_docs/version-29.2/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.2/Troubleshooting.md +++ b/website/versioned_docs/version-29.2/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.2/TutorialAsync.md b/website/versioned_docs/version-29.2/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.2/TutorialAsync.md +++ b/website/versioned_docs/version-29.2/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.2/TutorialReact.md b/website/versioned_docs/version-29.2/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-29.2/TutorialReact.md +++ b/website/versioned_docs/version-29.2/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-29.2/TutorialReactNative.md b/website/versioned_docs/version-29.2/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/website/versioned_docs/version-29.2/TutorialReactNative.md +++ b/website/versioned_docs/version-29.2/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.2/TutorialjQuery.md b/website/versioned_docs/version-29.2/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.2/TutorialjQuery.md +++ b/website/versioned_docs/version-29.2/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.2/UpgradingToJest29.md b/website/versioned_docs/version-29.2/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.2/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.2/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.2/WatchPlugins.md b/website/versioned_docs/version-29.2/WatchPlugins.md index acb66e0a8673..57ddeaec07e4 100644 --- a/website/versioned_docs/version-29.2/WatchPlugins.md +++ b/website/versioned_docs/version-29.2/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.3/CodeTransformation.md b/website/versioned_docs/version-29.3/CodeTransformation.md index 625b8d4fb27d..6e7f4cbeb969 100644 --- a/website/versioned_docs/version-29.3/CodeTransformation.md +++ b/website/versioned_docs/version-29.3/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.3/Configuration.md b/website/versioned_docs/version-29.3/Configuration.md index bdf7c836db4f..6afcbbb778c7 100644 --- a/website/versioned_docs/version-29.3/Configuration.md +++ b/website/versioned_docs/version-29.3/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -1330,7 +1330,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1512,7 +1512,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1766,7 +1766,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1789,9 +1789,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2078,7 +2078,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2118,7 +2118,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2160,7 +2160,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2375,7 +2375,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2393,7 +2393,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.3/ECMAScriptModules.md b/website/versioned_docs/version-29.3/ECMAScriptModules.md index 1aa9a39b0c68..feaed6bdb961 100644 --- a/website/versioned_docs/version-29.3/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.3/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -48,7 +48,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.3/ExpectAPI.md b/website/versioned_docs/version-29.3/ExpectAPI.md index f235097bda20..caba37d13841 100644 --- a/website/versioned_docs/version-29.3/ExpectAPI.md +++ b/website/versioned_docs/version-29.3/ExpectAPI.md @@ -281,7 +281,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.3/GlobalAPI.md b/website/versioned_docs/version-29.3/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.3/GlobalAPI.md +++ b/website/versioned_docs/version-29.3/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.3/JestObjectAPI.md b/website/versioned_docs/version-29.3/JestObjectAPI.md index 94d0f99115d9..472b7f1c3800 100644 --- a/website/versioned_docs/version-29.3/JestObjectAPI.md +++ b/website/versioned_docs/version-29.3/JestObjectAPI.md @@ -960,7 +960,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.3/JestPlatform.md b/website/versioned_docs/version-29.3/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.3/JestPlatform.md +++ b/website/versioned_docs/version-29.3/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.3/ManualMocks.md b/website/versioned_docs/version-29.3/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.3/ManualMocks.md +++ b/website/versioned_docs/version-29.3/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.3/MoreResources.md b/website/versioned_docs/version-29.3/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.3/MoreResources.md +++ b/website/versioned_docs/version-29.3/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.3/Puppeteer.md b/website/versioned_docs/version-29.3/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.3/Puppeteer.md +++ b/website/versioned_docs/version-29.3/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.3/SnapshotTesting.md b/website/versioned_docs/version-29.3/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.3/SnapshotTesting.md +++ b/website/versioned_docs/version-29.3/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.3/Troubleshooting.md b/website/versioned_docs/version-29.3/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.3/Troubleshooting.md +++ b/website/versioned_docs/version-29.3/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.3/TutorialAsync.md b/website/versioned_docs/version-29.3/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.3/TutorialAsync.md +++ b/website/versioned_docs/version-29.3/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.3/TutorialReact.md b/website/versioned_docs/version-29.3/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-29.3/TutorialReact.md +++ b/website/versioned_docs/version-29.3/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-29.3/TutorialReactNative.md b/website/versioned_docs/version-29.3/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/website/versioned_docs/version-29.3/TutorialReactNative.md +++ b/website/versioned_docs/version-29.3/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.3/TutorialjQuery.md b/website/versioned_docs/version-29.3/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.3/TutorialjQuery.md +++ b/website/versioned_docs/version-29.3/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.3/UpgradingToJest29.md b/website/versioned_docs/version-29.3/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.3/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.3/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.3/WatchPlugins.md b/website/versioned_docs/version-29.3/WatchPlugins.md index acb66e0a8673..57ddeaec07e4 100644 --- a/website/versioned_docs/version-29.3/WatchPlugins.md +++ b/website/versioned_docs/version-29.3/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.4/CodeTransformation.md b/website/versioned_docs/version-29.4/CodeTransformation.md index d2a568fcb024..14d96a16f649 100644 --- a/website/versioned_docs/version-29.4/CodeTransformation.md +++ b/website/versioned_docs/version-29.4/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.4/Configuration.md b/website/versioned_docs/version-29.4/Configuration.md index 6efbfb7fbc45..ed92e8e2bef9 100644 --- a/website/versioned_docs/version-29.4/Configuration.md +++ b/website/versioned_docs/version-29.4/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -1330,7 +1330,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1512,7 +1512,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1766,7 +1766,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1789,9 +1789,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2078,7 +2078,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2118,7 +2118,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2160,7 +2160,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2375,7 +2375,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2393,7 +2393,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.4/ECMAScriptModules.md b/website/versioned_docs/version-29.4/ECMAScriptModules.md index 1aa9a39b0c68..feaed6bdb961 100644 --- a/website/versioned_docs/version-29.4/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.4/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -48,7 +48,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.4/ExpectAPI.md b/website/versioned_docs/version-29.4/ExpectAPI.md index d140e0dd4340..46b2c361585e 100644 --- a/website/versioned_docs/version-29.4/ExpectAPI.md +++ b/website/versioned_docs/version-29.4/ExpectAPI.md @@ -1591,7 +1591,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.4/GlobalAPI.md b/website/versioned_docs/version-29.4/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.4/GlobalAPI.md +++ b/website/versioned_docs/version-29.4/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.4/JestObjectAPI.md b/website/versioned_docs/version-29.4/JestObjectAPI.md index a4619d66ca31..1a415aa24b87 100644 --- a/website/versioned_docs/version-29.4/JestObjectAPI.md +++ b/website/versioned_docs/version-29.4/JestObjectAPI.md @@ -1031,7 +1031,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.4/JestPlatform.md b/website/versioned_docs/version-29.4/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.4/JestPlatform.md +++ b/website/versioned_docs/version-29.4/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.4/ManualMocks.md b/website/versioned_docs/version-29.4/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.4/ManualMocks.md +++ b/website/versioned_docs/version-29.4/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.4/MoreResources.md b/website/versioned_docs/version-29.4/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.4/MoreResources.md +++ b/website/versioned_docs/version-29.4/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.4/Puppeteer.md b/website/versioned_docs/version-29.4/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.4/Puppeteer.md +++ b/website/versioned_docs/version-29.4/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.4/SnapshotTesting.md b/website/versioned_docs/version-29.4/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.4/SnapshotTesting.md +++ b/website/versioned_docs/version-29.4/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.4/Troubleshooting.md b/website/versioned_docs/version-29.4/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.4/Troubleshooting.md +++ b/website/versioned_docs/version-29.4/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.4/TutorialAsync.md b/website/versioned_docs/version-29.4/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.4/TutorialAsync.md +++ b/website/versioned_docs/version-29.4/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.4/TutorialReact.md b/website/versioned_docs/version-29.4/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-29.4/TutorialReact.md +++ b/website/versioned_docs/version-29.4/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-29.4/TutorialReactNative.md b/website/versioned_docs/version-29.4/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/website/versioned_docs/version-29.4/TutorialReactNative.md +++ b/website/versioned_docs/version-29.4/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.4/TutorialjQuery.md b/website/versioned_docs/version-29.4/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.4/TutorialjQuery.md +++ b/website/versioned_docs/version-29.4/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.4/UpgradingToJest29.md b/website/versioned_docs/version-29.4/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.4/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.4/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.4/WatchPlugins.md b/website/versioned_docs/version-29.4/WatchPlugins.md index acb66e0a8673..57ddeaec07e4 100644 --- a/website/versioned_docs/version-29.4/WatchPlugins.md +++ b/website/versioned_docs/version-29.4/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.5/CodeTransformation.md b/website/versioned_docs/version-29.5/CodeTransformation.md index d2a568fcb024..14d96a16f649 100644 --- a/website/versioned_docs/version-29.5/CodeTransformation.md +++ b/website/versioned_docs/version-29.5/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.5/Configuration.md b/website/versioned_docs/version-29.5/Configuration.md index b9ac0d926541..0604ca6f965a 100644 --- a/website/versioned_docs/version-29.5/Configuration.md +++ b/website/versioned_docs/version-29.5/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -1365,7 +1365,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1547,7 +1547,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1801,7 +1801,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1824,9 +1824,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2113,7 +2113,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2153,7 +2153,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2195,7 +2195,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2410,7 +2410,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2428,7 +2428,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.5/ECMAScriptModules.md b/website/versioned_docs/version-29.5/ECMAScriptModules.md index 1aa9a39b0c68..feaed6bdb961 100644 --- a/website/versioned_docs/version-29.5/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.5/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -48,7 +48,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.5/ExpectAPI.md b/website/versioned_docs/version-29.5/ExpectAPI.md index d140e0dd4340..46b2c361585e 100644 --- a/website/versioned_docs/version-29.5/ExpectAPI.md +++ b/website/versioned_docs/version-29.5/ExpectAPI.md @@ -1591,7 +1591,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.5/GlobalAPI.md b/website/versioned_docs/version-29.5/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.5/GlobalAPI.md +++ b/website/versioned_docs/version-29.5/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.5/JestObjectAPI.md b/website/versioned_docs/version-29.5/JestObjectAPI.md index d3811b628b86..130e6d7768a2 100644 --- a/website/versioned_docs/version-29.5/JestObjectAPI.md +++ b/website/versioned_docs/version-29.5/JestObjectAPI.md @@ -1071,7 +1071,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.5/JestPlatform.md b/website/versioned_docs/version-29.5/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.5/JestPlatform.md +++ b/website/versioned_docs/version-29.5/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.5/ManualMocks.md b/website/versioned_docs/version-29.5/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.5/ManualMocks.md +++ b/website/versioned_docs/version-29.5/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.5/MoreResources.md b/website/versioned_docs/version-29.5/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.5/MoreResources.md +++ b/website/versioned_docs/version-29.5/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.5/Puppeteer.md b/website/versioned_docs/version-29.5/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.5/Puppeteer.md +++ b/website/versioned_docs/version-29.5/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.5/SnapshotTesting.md b/website/versioned_docs/version-29.5/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.5/SnapshotTesting.md +++ b/website/versioned_docs/version-29.5/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.5/Troubleshooting.md b/website/versioned_docs/version-29.5/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.5/Troubleshooting.md +++ b/website/versioned_docs/version-29.5/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.5/TutorialAsync.md b/website/versioned_docs/version-29.5/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.5/TutorialAsync.md +++ b/website/versioned_docs/version-29.5/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.5/TutorialReact.md b/website/versioned_docs/version-29.5/TutorialReact.md index 673122b5facb..88bb4ebc6fef 100644 --- a/website/versioned_docs/version-29.5/TutorialReact.md +++ b/website/versioned_docs/version-29.5/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). #### Enzyme diff --git a/website/versioned_docs/version-29.5/TutorialReactNative.md b/website/versioned_docs/version-29.5/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/website/versioned_docs/version-29.5/TutorialReactNative.md +++ b/website/versioned_docs/version-29.5/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.5/TutorialjQuery.md b/website/versioned_docs/version-29.5/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.5/TutorialjQuery.md +++ b/website/versioned_docs/version-29.5/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.5/UpgradingToJest29.md b/website/versioned_docs/version-29.5/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.5/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.5/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.5/WatchPlugins.md b/website/versioned_docs/version-29.5/WatchPlugins.md index acb66e0a8673..57ddeaec07e4 100644 --- a/website/versioned_docs/version-29.5/WatchPlugins.md +++ b/website/versioned_docs/version-29.5/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript diff --git a/website/versioned_docs/version-29.6/CodeTransformation.md b/website/versioned_docs/version-29.6/CodeTransformation.md index d2a568fcb024..14d96a16f649 100644 --- a/website/versioned_docs/version-29.6/CodeTransformation.md +++ b/website/versioned_docs/version-29.6/CodeTransformation.md @@ -13,7 +13,7 @@ Jest will cache the result of a transformation and attempt to invalidate that re ## Defaults -Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest ships with one transformer out of the box – [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup). It will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). :::tip @@ -134,7 +134,7 @@ type TransformerFactory = { :::note -The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/facebook/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). +The definitions above were trimmed down for brevity. Full code can be found in [Jest repo on GitHub](https://github.com/jestjs/jest/blob/main/packages/jest-transform/src/types.ts) (remember to choose the right tag/commit for your version of Jest). ::: diff --git a/website/versioned_docs/version-29.6/Configuration.md b/website/versioned_docs/version-29.6/Configuration.md index 0fe862f4bb3d..4e23e314b103 100644 --- a/website/versioned_docs/version-29.6/Configuration.md +++ b/website/versioned_docs/version-29.6/Configuration.md @@ -310,7 +310,7 @@ const config: Config = { export default config; ``` -For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Config.ts). +For more information about the options object shape refer to `CoverageReporterWithOptions` type in the [type definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Config.ts). ### `coverageThreshold` \[object] @@ -772,7 +772,7 @@ If you specify a global reference value (like an object or array) here, and some Default: `undefined` -This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global setup module, which must export a function (it can be sync or async). The function will be triggered once before all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -807,7 +807,7 @@ module.exports = async function (globalConfig, projectConfig) { Default: `undefined` -This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). +This option allows the use of a custom global teardown module which must export a function (it can be sync or async). The function will be triggered once after all test suites and it will receive two arguments: Jest's [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481). :::info @@ -1401,7 +1401,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): ```js title="custom-reporter.js" class CustomReporter { @@ -1583,7 +1583,7 @@ The `runner` property value can omit the `jest-runner-` prefix of the package na ::: -To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: +To write a test-runner, export a class with which accepts [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) in the constructor, and has a `runTests` method with the signature: ```ts async function runTests( @@ -1837,7 +1837,7 @@ Pretty foo: Object { To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration. -More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize). +More about serializers API can be found [here](https://github.com/jestjs/jest/tree/main/packages/pretty-format/README.md#serialize). ::: @@ -1860,9 +1860,9 @@ test('use jsdom in this test file', () => { }); ``` -You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/facebook/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. +You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `getVmContext` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. The constructor is passed [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422) and [`projectConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L424-L481) as its first argument, and [`testEnvironmentContext`](https://github.com/jestjs/jest/blob/491e7cb0f2daa8263caccc72d48bdce7ba759b11/packages/jest-environment/src/index.ts#L13) as its second. -The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. +The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/jestjs/jest/tree/main/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/jestjs/jest/tree/main/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases. Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. @@ -2149,7 +2149,7 @@ function testRunner( ): Promise; ``` -An example of such function can be found in our default [jasmine2 test runner package](https://github.com/facebook/jest/blob/main/packages/jest-jasmine2/src/index.ts). +An example of such function can be found in our default [jasmine2 test runner package](https://github.com/jestjs/jest/blob/main/packages/jest-jasmine2/src/index.ts). ### `testSequencer` \[string] @@ -2189,7 +2189,7 @@ class CustomSequencer extends Sequencer { */ sort(tests) { // Test structure information - // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 + // https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21 const copyTests = Array.from(tests); return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); } @@ -2231,7 +2231,7 @@ Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. Optionally, a tuple with configuration options can be passed as second argument: `{filePattern: ['path-to-transformer', {options}]}`. For example, here is how you can configure `babel-jest` for non-default behavior: `{'\\.js$': ['babel-jest', {rootMode: 'upward'}]}`. -Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/facebook/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). +Jest runs the code of your project as JavaScript, hence a transformer is needed if you use some syntax not supported by Node out of the box (such as JSX, TypeScript, Vue templates). By default, Jest will use [`babel-jest`](https://github.com/jestjs/jest/tree/main/packages/babel-jest#setup) transformer, which will load your project's Babel configuration and transform any file matching the `/\.[jt]sx?$/` RegExp (in other words, any `.js`, `.jsx`, `.ts` or `.tsx` file). In addition, `babel-jest` will inject the Babel plugin necessary for mock hoisting talked about in [ES Module mocking](ManualMocks.md#using-with-es-module-imports). See the [Code Transformation](CodeTransformation.md) section for more details and instructions on building your own transformer. @@ -2446,7 +2446,7 @@ Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawl Default: `undefined` -Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/facebook/jest/issues/11956); +Specifies the memory limit for workers before they are recycled and is primarily a work-around for [this issue](https://github.com/jestjs/jest/issues/11956); After the worker has executed a test the memory usage of it is checked. If it exceeds the value specified the worker is killed and restarted. The limit can be specified in a number of different ways and whatever the result is `Math.floor` is used to turn it into an integer value: @@ -2464,7 +2464,7 @@ After the worker has executed a test the memory usage of it is checked. If it ex :::caution -Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/facebook/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. +Percentage based memory limit [does not work on Linux CircleCI workers](https://github.com/jestjs/jest/issues/11956#issuecomment-1212925677) due to incorrect system memory being reported. ::: diff --git a/website/versioned_docs/version-29.6/ECMAScriptModules.md b/website/versioned_docs/version-29.6/ECMAScriptModules.md index 1aa9a39b0c68..feaed6bdb961 100644 --- a/website/versioned_docs/version-29.6/ECMAScriptModules.md +++ b/website/versioned_docs/version-29.6/ECMAScriptModules.md @@ -7,7 +7,7 @@ title: ECMAScript Modules Jest ships with **experimental** support for ECMAScript Modules (ESM). -The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. +The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/jestjs/jest/issues/9430) and the [label](https://github.com/jestjs/jest/labels/ES%20Modules) on the issue tracker. Also note that the APIs Jest uses to implement ESM support are still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `18.8.0`). @@ -48,7 +48,7 @@ import.meta.jest.useFakeTimers(); Since ESM evaluates static `import` statements before looking at the code, the hoisting of `jest.mock` calls that happens in CJS won't work for ESM. To mock modules in ESM, you need to use `require` or dynamic `import()` after `jest.mock` calls to load the mocked modules - the same applies to modules which load the mocked modules. -ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. +ESM mocking is supported through `jest.unstable_mockModule`. As the name suggests, this API is still work in progress, please follow [this issue](https://github.com/jestjs/jest/issues/10025) for updates. The usage of `jest.unstable_mockModule` is essentially the same as `jest.mock` with two differences: the factory function is required and it can be sync or async: diff --git a/website/versioned_docs/version-29.6/ExpectAPI.md b/website/versioned_docs/version-29.6/ExpectAPI.md index d140e0dd4340..46b2c361585e 100644 --- a/website/versioned_docs/version-29.6/ExpectAPI.md +++ b/website/versioned_docs/version-29.6/ExpectAPI.md @@ -1591,7 +1591,7 @@ A boolean to let you know this matcher was called with an `expand` option. When #### `this.utils` -There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/facebook/jest/tree/main/packages/jest-matcher-utils). +There are a number of helpful tools exposed on `this.utils` primarily consisting of the exports from [`jest-matcher-utils`](https://github.com/jestjs/jest/tree/main/packages/jest-matcher-utils). The most useful ones are `matcherHint`, `printExpected` and `printReceived` to format the error messages nicely. For example, take a look at the implementation for the `toBe` matcher: diff --git a/website/versioned_docs/version-29.6/GlobalAPI.md b/website/versioned_docs/version-29.6/GlobalAPI.md index 7a29a37a7ec1..c3a14d3c542c 100644 --- a/website/versioned_docs/version-29.6/GlobalAPI.md +++ b/website/versioned_docs/version-29.6/GlobalAPI.md @@ -505,7 +505,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)` :::caution -`test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. +`test.concurrent` is considered experimental - see [here](https://github.com/jestjs/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues. ::: @@ -751,7 +751,7 @@ Also under the alias: `it.failing(name, fn, timeout)` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -783,7 +783,7 @@ Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each` :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -807,7 +807,7 @@ Also under the aliases: `it.only.failing(name, fn, timeout)`, `fit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: @@ -819,7 +819,7 @@ Also under the aliases: `it.skip.failing(name, fn, timeout)`, `xit.failing(name, :::note -This is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.6/JestObjectAPI.md b/website/versioned_docs/version-29.6/JestObjectAPI.md index d3811b628b86..130e6d7768a2 100644 --- a/website/versioned_docs/version-29.6/JestObjectAPI.md +++ b/website/versioned_docs/version-29.6/JestObjectAPI.md @@ -1071,7 +1071,7 @@ Returns the `jest` object for chaining. :::info -This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner. +This function is only available with the default [jest-circus](https://github.com/jestjs/jest/tree/main/packages/jest-circus) runner. ::: diff --git a/website/versioned_docs/version-29.6/JestPlatform.md b/website/versioned_docs/version-29.6/JestPlatform.md index 7e638e040b63..3e0ed9f07956 100644 --- a/website/versioned_docs/version-29.6/JestPlatform.md +++ b/website/versioned_docs/version-29.6/JestPlatform.md @@ -23,7 +23,7 @@ getChangedFilesForRoots(['./'], { }).then(result => console.log(result.changedFiles)); ``` -You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-changed-files/README.md). +You can read more about `jest-changed-files` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-changed-files/README.md). ## jest-diff @@ -68,7 +68,7 @@ const parsed = parseWithComments(code); console.log(parsed); ``` -You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-docblock/README.md). +You can read more about `jest-docblock` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-docblock/README.md). ## jest-get-type @@ -115,7 +115,7 @@ const result = validate(configByUser, { console.log(result); ``` -You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-validate/README.md). +You can read more about `jest-validate` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-validate/README.md). ## jest-worker @@ -147,7 +147,7 @@ async function main() { main(); ``` -You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/main/packages/jest-worker/README.md). +You can read more about `jest-worker` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/jest-worker/README.md). ## pretty-format @@ -167,4 +167,4 @@ val.array = [-0, Infinity, NaN]; console.log(prettyFormat(val)); ``` -You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/main/packages/pretty-format/README.md). +You can read more about `pretty-format` in the [readme file](https://github.com/jestjs/jest/blob/main/packages/pretty-format/README.md). diff --git a/website/versioned_docs/version-29.6/ManualMocks.md b/website/versioned_docs/version-29.6/ManualMocks.md index 48e5acdb21fc..d166114387eb 100644 --- a/website/versioned_docs/version-29.6/ManualMocks.md +++ b/website/versioned_docs/version-29.6/ManualMocks.md @@ -142,7 +142,7 @@ The example mock shown here uses [`jest.createMockFromModule`](JestObjectAPI.md# To ensure that a manual mock and its real implementation stay in sync, it might be useful to require the real module using [`jest.requireActual(moduleName)`](JestObjectAPI.md#jestrequireactualmodulename) in your manual mock and amending it with mock functions before exporting it. -The code for this example is available at [examples/manual-mocks](https://github.com/facebook/jest/tree/main/examples/manual-mocks). +The code for this example is available at [examples/manual-mocks](https://github.com/jestjs/jest/tree/main/examples/manual-mocks). ## Using with ES module imports diff --git a/website/versioned_docs/version-29.6/MoreResources.md b/website/versioned_docs/version-29.6/MoreResources.md index 32335ceacbf2..a53696153a7b 100644 --- a/website/versioned_docs/version-29.6/MoreResources.md +++ b/website/versioned_docs/version-29.6/MoreResources.md @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can help you test your applicatio ## Learn by example -You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. +You will find a number of example test cases in the [`examples`](https://github.com/jestjs/jest/tree/main/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/main/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/main/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/main/Libraries/Animated/__tests__) projects. ## Join the community diff --git a/website/versioned_docs/version-29.6/Puppeteer.md b/website/versioned_docs/version-29.6/Puppeteer.md index d437bda3743f..5f2a6ef2806c 100644 --- a/website/versioned_docs/version-29.6/Puppeteer.md +++ b/website/versioned_docs/version-29.6/Puppeteer.md @@ -7,7 +7,7 @@ With the [Global Setup/Teardown](Configuration.md#globalsetup-string) and [Async :::note -Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/facebook/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. +Generating code coverage for test files using Puppeteer is currently not possible if your test uses `page.$eval`, `page.$$eval` or `page.evaluate` as the passed function is executed outside of Jest's scope. Check out [issue #7962](https://github.com/jestjs/jest/issues/7962#issuecomment-495272339) on GitHub for a workaround. ::: diff --git a/website/versioned_docs/version-29.6/SnapshotTesting.md b/website/versioned_docs/version-29.6/SnapshotTesting.md index 2fcef23b1579..3a58dbc0a347 100644 --- a/website/versioned_docs/version-29.6/SnapshotTesting.md +++ b/website/versioned_docs/version-29.6/SnapshotTesting.md @@ -9,7 +9,7 @@ A typical snapshot test case renders a UI component, takes a snapshot, then comp ## Snapshot Testing with Jest -A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/facebook/jest/blob/main/examples/snapshot/Link.js): +A similar approach can be taken when it comes to testing your React components. Instead of rendering the graphical UI, which would require building the entire app, you can use a test renderer to quickly generate a serializable value for your React tree. Consider this [example test](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js) for a [Link component](https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js): ```tsx import renderer from 'react-test-renderer'; @@ -23,7 +23,7 @@ it('renders correctly', () => { }); ``` -The first time this test is run, Jest creates a [snapshot file](https://github.com/facebook/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: +The first time this test is run, Jest creates a [snapshot file](https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap) that looks like this: ```javascript exports[`renders correctly 1`] = ` @@ -38,7 +38,7 @@ exports[`renders correctly 1`] = ` `; ``` -The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. +The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/jestjs/jest/tree/main/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated. :::note @@ -84,7 +84,7 @@ Go ahead and accept the changes by running the above command. You may also use t If you'd like to limit which snapshot test cases get re-generated, you can pass an additional `--testNamePattern` flag to re-record snapshots only for those tests that match the pattern. -You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. +You can try out this functionality by cloning the [snapshot example](https://github.com/jestjs/jest/tree/main/examples/snapshot), modifying the `Link` component, and running Jest. ### Interactive Snapshot Mode @@ -252,7 +252,7 @@ The goal is to make it easy to review snapshots in pull requests, and fight agai Your tests should be deterministic. Running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data. -For example, if you have a [Clock](https://github.com/facebook/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: +For example, if you have a [Clock](https://github.com/jestjs/jest/blob/main/examples/snapshot/Clock.js) component that uses `Date.now()`, the snapshot generated from this component will be different every time the test case is run. In this case we can [mock the Date.now() method](MockFunctions.md) to return a consistent value every time the test is run: ```js Date.now = jest.fn(() => 1482363367071); @@ -312,7 +312,7 @@ Yes, all snapshot files should be committed alongside the modules they are cover ### Does snapshot testing only work with React components? -[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/facebook/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. +[React](TutorialReact.md) and [React Native](TutorialReactNative.md) components are a good use case for snapshot testing. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. The Jest repository contains many examples of testing the output of Jest itself, the output of Jest's assertion library as well as log messages from various parts of the Jest codebase. See an example of [snapshotting CLI output](https://github.com/jestjs/jest/blob/main/e2e/__tests__/console.test.ts) in the Jest repo. ### What's the difference between snapshot testing and visual regression testing? diff --git a/website/versioned_docs/version-29.6/Troubleshooting.md b/website/versioned_docs/version-29.6/Troubleshooting.md index 42afe50c2f14..ffa30a558854 100644 --- a/website/versioned_docs/version-29.6/Troubleshooting.md +++ b/website/versioned_docs/version-29.6/Troubleshooting.md @@ -161,9 +161,9 @@ Also see [watchman troubleshooting](https://facebook.github.io/watchman/docs/tro ## Tests are Extremely Slow on Docker and/or Continuous Integration (CI) server. -While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/facebook/jest/issues/1395) [discovered](https://github.com/facebook/jest/issues/1524#issuecomment-260246008). +While Jest is most of the time extremely fast on modern multi-core computers with fast SSDs, it may be slow on certain setups as our users [have](https://github.com/jestjs/jest/issues/1395) [discovered](https://github.com/jestjs/jest/issues/1524#issuecomment-260246008). -Based on the [findings](https://github.com/facebook/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. +Based on the [findings](https://github.com/jestjs/jest/issues/1524#issuecomment-262366820), one way to mitigate this issue and improve the speed by up to 50% is to run tests sequentially. In order to do this you can run tests in the same thread using [`--runInBand`](CLI.md#--runinband): diff --git a/website/versioned_docs/version-29.6/TutorialAsync.md b/website/versioned_docs/version-29.6/TutorialAsync.md index 80acc323a22e..4f9e4c4d5d24 100644 --- a/website/versioned_docs/version-29.6/TutorialAsync.md +++ b/website/versioned_docs/version-29.6/TutorialAsync.md @@ -156,6 +156,6 @@ it('tests error with async/await and rejects', async () => { }); ``` -The code for this example is available at [examples/async](https://github.com/facebook/jest/tree/main/examples/async). +The code for this example is available at [examples/async](https://github.com/jestjs/jest/tree/main/examples/async). If you'd like to test timers, like `setTimeout`, take a look at the [Timer mocks](TimerMocks.md) documentation. diff --git a/website/versioned_docs/version-29.6/TutorialReact.md b/website/versioned_docs/version-29.6/TutorialReact.md index 13165b1b4e95..fd6f7620acce 100644 --- a/website/versioned_docs/version-29.6/TutorialReact.md +++ b/website/versioned_docs/version-29.6/TutorialReact.md @@ -171,7 +171,7 @@ exports[`changes the class when hovered 3`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/snapshot](https://github.com/facebook/jest/tree/main/examples/snapshot). +The code for this example is available at [examples/snapshot](https://github.com/jestjs/jest/tree/main/examples/snapshot). #### Snapshot Testing with Mocks, Enzyme and React 16+ @@ -259,7 +259,7 @@ it('CheckboxWithLabel changes the text after click', () => { }); ``` -The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library). +The code for this example is available at [examples/react-testing-library](https://github.com/jestjs/jest/tree/main/examples/react-testing-library). ### Custom transformers diff --git a/website/versioned_docs/version-29.6/TutorialReactNative.md b/website/versioned_docs/version-29.6/TutorialReactNative.md index b2b653078a85..4cd9a78a9a57 100644 --- a/website/versioned_docs/version-29.6/TutorialReactNative.md +++ b/website/versioned_docs/version-29.6/TutorialReactNative.md @@ -125,7 +125,7 @@ exports[`Intro renders correctly 1`] = ` The next time you run the tests, the rendered output will be compared to the previously created snapshot. The snapshot should be committed along with code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change. If the change is expected you can invoke Jest with `jest -u` to overwrite the existing snapshot. -The code for this example is available at [examples/react-native](https://github.com/facebook/jest/tree/main/examples/react-native). +The code for this example is available at [examples/react-native](https://github.com/jestjs/jest/tree/main/examples/react-native). ## Preset configuration diff --git a/website/versioned_docs/version-29.6/TutorialjQuery.md b/website/versioned_docs/version-29.6/TutorialjQuery.md index 9f1be7caf513..a1c542a4f12b 100644 --- a/website/versioned_docs/version-29.6/TutorialjQuery.md +++ b/website/versioned_docs/version-29.6/TutorialjQuery.md @@ -69,4 +69,4 @@ To get started with the JSDOM [test environment](Configuration.md#testenvironmen npm install --save-dev jest-environment-jsdom ``` -The code for this example is available at [examples/jquery](https://github.com/facebook/jest/tree/main/examples/jquery). +The code for this example is available at [examples/jquery](https://github.com/jestjs/jest/tree/main/examples/jquery). diff --git a/website/versioned_docs/version-29.6/UpgradingToJest29.md b/website/versioned_docs/version-29.6/UpgradingToJest29.md index 49caf1de4736..842092f445c3 100644 --- a/website/versioned_docs/version-29.6/UpgradingToJest29.md +++ b/website/versioned_docs/version-29.6/UpgradingToJest29.md @@ -7,7 +7,7 @@ Upgrading Jest from v28 to v29? This guide aims to help refactoring your configu :::info -See [changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. +See [changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900) for the full list of changes. ::: diff --git a/website/versioned_docs/version-29.6/WatchPlugins.md b/website/versioned_docs/version-29.6/WatchPlugins.md index acb66e0a8673..57ddeaec07e4 100644 --- a/website/versioned_docs/version-29.6/WatchPlugins.md +++ b/website/versioned_docs/version-29.6/WatchPlugins.md @@ -140,7 +140,7 @@ If the key for your plugin already exists as a default key, your plugin will ove To handle key press events from the key returned by `getUsageInfo`, you can implement the `run` method. This method returns a `Promise` that can be resolved when the plugin wants to return control to Jest. The `boolean` specifies if Jest should rerun the tests after it gets the control back. -- [`globalConfig`](https://github.com/facebook/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration +- [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422): A representation of Jest's current global configuration - `updateConfigAndRun`: Allows you to trigger a test run while the interactive plugin is running. ```javascript