From ea58362ffd6aa091722e92216e3e9ec85163e23d Mon Sep 17 00:00:00 2001 From: Paul Draper Date: Sun, 20 Feb 2022 01:07:19 -0700 Subject: [PATCH] Allow Jest to run tests in node_modules Resolves #2145 and #11781. Prevent haste map from automatically discarding node_modules files. By default, node_modules is still excluded via the testPathIgnorePatterns option. However, users can now use that option to allow node_modules without hacks. --- CHANGELOG.md | 1 + packages/jest-runtime/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f3284eb17e..bf804295d94e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - `[jest-haste-map]` Don't use partial results if file crawl errors ([#12420](https://github.com/facebook/jest/pull/12420)) - `[jest-jasmine2, jest-types]` [**BREAKING**] Move all `jasmine` specific types from `@jest/types` to its own package ([#12125](https://github.com/facebook/jest/pull/12125)) - `[jest-matcher-utils]` Pass maxWidth to `pretty-format` to avoid printing every element in arrays by default ([#12402](https://github.com/facebook/jest/pull/12402)) +- `[jest-runtime]` Permit tests in node_modules ([#12438](https://github.com/facebook/jest/pull/12438)) ### Chore & Maintenance diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 363eef8f90cb..c3e5958153d6 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -386,7 +386,7 @@ export default class Runtime { name: config.name, platforms: config.haste.platforms || ['ios', 'android'], resetCache: options?.resetCache, - retainAllFiles: false, + retainAllFiles: true, rootDir: config.rootDir, roots: config.roots, throwOnModuleCollision: config.haste.throwOnModuleCollision,