From 76b1fc12159112d0d85f55594e35dc7f4a021129 Mon Sep 17 00:00:00 2001 From: Christopher Roberts Date: Sat, 13 Feb 2021 16:36:41 -0500 Subject: [PATCH] fix: Allow searching for tests in node_modules --- CHANGELOG.md | 1 + docs/Configuration.md | 2 ++ packages/jest-config/src/ValidConfig.ts | 1 + packages/jest-haste-map/src/types.ts | 1 + packages/jest-types/src/Config.ts | 2 ++ 5 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dc8f3169adf..2012042ee4bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ - `[jest-worker]` Do not swallow errors during serialization ([#10984](https://github.com/facebook/jest/pull/10984)) - `[pretty-format]` [**BREAKING**] Convert to ES Modules ([#10515](https://github.com/facebook/jest/pull/10515)) - `[pretty-format]` Only call `hasAttribute` if it's a function ([#11000](https://github.com/facebook/jest/pull/11000)) +- `[jest-config]` Allow searching for tests in node_modules by exposing `retainAllFiles` ([#11084](https://github.com/facebook/jest/pull/11084)) ### Chore & Maintenance diff --git a/docs/Configuration.md b/docs/Configuration.md index d0f895117465..0a9f6092b773 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -499,6 +499,8 @@ type HasteConfig = { platforms?: Array; // Whether to throw on error on module collision. throwOnModuleCollision?: boolean; + // Whether to search for tests in node_modules. + retainAllFiles?: boolean; }; ``` diff --git a/packages/jest-config/src/ValidConfig.ts b/packages/jest-config/src/ValidConfig.ts index 2c7338301e07..294f8096e0b0 100644 --- a/packages/jest-config/src/ValidConfig.ts +++ b/packages/jest-config/src/ValidConfig.ts @@ -58,6 +58,7 @@ const initialOptions: Config.InitialOptions = { hasteImplModulePath: '/haste_impl.js', platforms: ['ios', 'android'], throwOnModuleCollision: false, + retainAllFiles: false }, injectGlobals: true, json: false, diff --git a/packages/jest-haste-map/src/types.ts b/packages/jest-haste-map/src/types.ts index 61dee043c751..5d3fade4f2b1 100644 --- a/packages/jest-haste-map/src/types.ts +++ b/packages/jest-haste-map/src/types.ts @@ -19,6 +19,7 @@ export type WorkerMessage = { rootDir: string; filePath: string; hasteImplModulePath?: string; + retainAllFiles?: boolean; }; export type WorkerMetadata = { diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 8b8243994a0e..56af55b53737 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -28,6 +28,8 @@ export type HasteConfig = { platforms?: Array; /** Whether to throw on error on module collision. */ throwOnModuleCollision?: boolean; + /** Whether to search for tests in node_modules. */ + retainAllFiles?: boolean; }; export type CoverageReporterName = keyof ReportOptions;