diff --git a/packages/jest-core/src/getChangedFilesPromise.ts b/packages/jest-core/src/getChangedFilesPromise.ts index 570a13d754eb..390851254daf 100644 --- a/packages/jest-core/src/getChangedFilesPromise.ts +++ b/packages/jest-core/src/getChangedFilesPromise.ts @@ -16,7 +16,12 @@ export default ( ): ChangedFilesPromise | undefined => { if (globalConfig.onlyChanged) { const allRootsForAllProjects = configs.reduce>( - (roots, config) => [...roots, ...(config.roots || [])], + (roots, config) => { + if (config.roots) { + roots.push(...config.roots); + } + return roots; + }, [], ); return getChangedFilesForRoots(allRootsForAllProjects, {