From 8c56d741e88b43ee41f384118c70c8f2cdd99db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A3=E9=87=8C=E5=A5=BD=E8=84=8F=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5?= <453491931@qq.com> Date: Mon, 22 Aug 2022 15:46:37 +0800 Subject: [PATCH] docs: Update Configuration.md for added special notes on usage scenarios for pnpm. (#13115) Co-authored-by: Gao Sheng --- docs/Configuration.md | 31 +++++++++++++++++++ .../version-25.x/Configuration.md | 16 ++++++++++ .../version-26.x/Configuration.md | 16 ++++++++++ .../version-27.x/Configuration.md | 16 ++++++++++ .../version-28.0/Configuration.md | 16 ++++++++++ .../version-28.1/Configuration.md | 16 ++++++++++ 6 files changed, 111 insertions(+) diff --git a/docs/Configuration.md b/docs/Configuration.md index e6079b7c4323..d6762ea4b695 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -2183,6 +2183,37 @@ const config: Config = { export default config; ``` +:::tip + +If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use: + +```js tab +/** @type {import('jest').Config} */ +const config = { + transformIgnorePatterns: [ + '/node_modules/.pnpm/(?!(package-a|package-b)@)', + ], +}; + +module.exports = config; +``` + +```ts tab +import type {Config} from 'jest'; + +const config: Config = { + transformIgnorePatterns: [ + '/node_modules/.pnpm/(?!(package-a|package-b)@)', + ], +}; + +export default config; +``` + +It should be noted that the folder name of pnpm under `.pnpm` is the package name plus `@` and version number, so writing `/` will not be recognized, but using `@` can. + +::: + ### `unmockedModulePathPatterns` \[array<string>] Default: `[]` diff --git a/website/versioned_docs/version-25.x/Configuration.md b/website/versioned_docs/version-25.x/Configuration.md index f13ea6bf026f..5eb00e3b00cc 100644 --- a/website/versioned_docs/version-25.x/Configuration.md +++ b/website/versioned_docs/version-25.x/Configuration.md @@ -1340,6 +1340,22 @@ Example: } ``` +:::tip + +If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use: + +```json +{ + "transformIgnorePatterns": [ + "/node_modules/.pnpm/(?!(package-a|package-b)@)" + ] +} +``` + +It should be noted that the folder name of pnpm under `.pnpm` is the package name plus `@` and version number, so writing `/` will not be recognized, but using `@` can. + +::: + ### `unmockedModulePathPatterns` \[array<string>] Default: `[]` diff --git a/website/versioned_docs/version-26.x/Configuration.md b/website/versioned_docs/version-26.x/Configuration.md index 13f8dd53e86e..672afbcd8b78 100644 --- a/website/versioned_docs/version-26.x/Configuration.md +++ b/website/versioned_docs/version-26.x/Configuration.md @@ -1340,6 +1340,22 @@ Example: } ``` +:::tip + +If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use: + +```json +{ + "transformIgnorePatterns": [ + "/node_modules/.pnpm/(?!(package-a|package-b)@)" + ] +} +``` + +It should be noted that the folder name of pnpm under `.pnpm` is the package name plus `@` and version number, so writing `/` will not be recognized, but using `@` can. + +::: + ### `unmockedModulePathPatterns` \[array<string>] Default: `[]` diff --git a/website/versioned_docs/version-27.x/Configuration.md b/website/versioned_docs/version-27.x/Configuration.md index fea8633d90f5..d453a21be98f 100644 --- a/website/versioned_docs/version-27.x/Configuration.md +++ b/website/versioned_docs/version-27.x/Configuration.md @@ -1409,6 +1409,22 @@ Example: } ``` +:::tip + +If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use: + +```json +{ + "transformIgnorePatterns": [ + "/node_modules/.pnpm/(?!(package-a|package-b)@)" + ] +} +``` + +It should be noted that the folder name of pnpm under `.pnpm` is the package name plus `@` and version number, so writing `/` will not be recognized, but using `@` can. + +::: + ### `unmockedModulePathPatterns` \[array<string>] Default: `[]` diff --git a/website/versioned_docs/version-28.0/Configuration.md b/website/versioned_docs/version-28.0/Configuration.md index 719550361156..a2c33ea92547 100644 --- a/website/versioned_docs/version-28.0/Configuration.md +++ b/website/versioned_docs/version-28.0/Configuration.md @@ -1647,6 +1647,22 @@ Example: } ``` +:::tip + +If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use: + +```json +{ + "transformIgnorePatterns": [ + "/node_modules/.pnpm/(?!(package-a|package-b)@)" + ] +} +``` + +It should be noted that the folder name of pnpm under `.pnpm` is the package name plus `@` and version number, so writing `/` will not be recognized, but using `@` can. + +::: + ### `unmockedModulePathPatterns` \[array<string>] Default: `[]` diff --git a/website/versioned_docs/version-28.1/Configuration.md b/website/versioned_docs/version-28.1/Configuration.md index 2fb7d6f518f1..21e70a8628ae 100644 --- a/website/versioned_docs/version-28.1/Configuration.md +++ b/website/versioned_docs/version-28.1/Configuration.md @@ -1651,6 +1651,22 @@ Example: } ``` +:::tip + +If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use: + +```json +{ + "transformIgnorePatterns": [ + "/node_modules/.pnpm/(?!(package-a|package-b)@)" + ] +} +``` + +It should be noted that the folder name of pnpm under `.pnpm` is the package name plus `@` and version number, so writing `/` will not be recognized, but using `@` can. + +::: + ### `unmockedModulePathPatterns` \[array<string>] Default: `[]`