diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a9eeb537f3c..1d5f09335eff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - `[expect]` Check constructor equality in .toStrictEqual() ([#7005](https://github.com/facebook/jest/pull/7005)) - `[jest-util]` Add `jest.getTimerCount()` to get the count of scheduled fake timers ([#7285](https://github.com/facebook/jest/pull/7285)) - `[jest-config]` Add `dependencyExtractor` option to use a custom module to extract dependencies from files ([#7313](https://github.com/facebook/jest/pull/7313)) +- `[jest-haste-map]` [**BREAKING**] Expose relative paths when getting the file iterator ([#XXX](https://github.com/facebook/jest/pull/XXX)) ### Fixes diff --git a/packages/jest-haste-map/src/HasteFS.js b/packages/jest-haste-map/src/HasteFS.js index 69df848a5975..03b60a1e946e 100644 --- a/packages/jest-haste-map/src/HasteFS.js +++ b/packages/jest-haste-map/src/HasteFS.js @@ -43,10 +43,14 @@ export default class HasteFS { } getAllFiles(): Array { - return Array.from(this.getFileIterator()); + return Array.from(this.getAbsoluteFileIterator()); } - *getFileIterator(): Iterator { + getFileIterator(): Iterator { + return this._files.keys(); + } + + *getAbsoluteFileIterator(): Iterator { for (const file of this._files.keys()) { yield fastPath.resolve(this._rootDir, file); } @@ -57,7 +61,7 @@ export default class HasteFS { pattern = new RegExp(pattern); } const files = []; - for (const file of this.getFileIterator()) { + for (const file of this.getAbsoluteFileIterator()) { if (pattern.test(file)) { files.push(file); } @@ -67,7 +71,7 @@ export default class HasteFS { matchFilesWithGlob(globs: Array, root: ?Path): Set { const files = new Set(); - for (const file of this.getFileIterator()) { + for (const file of this.getAbsoluteFileIterator()) { const filePath = root ? fastPath.relative(root, file) : file; if (micromatch([filePath], globs).length) { files.add(file); diff --git a/packages/jest-resolve-dependencies/src/index.js b/packages/jest-resolve-dependencies/src/index.js index b5e5f5a4efbc..64e3474037df 100644 --- a/packages/jest-resolve-dependencies/src/index.js +++ b/packages/jest-resolve-dependencies/src/index.js @@ -97,7 +97,7 @@ class DependencyResolver { } } const modules = []; - for (const file of this._hasteFS.getFileIterator()) { + for (const file of this._hasteFS.getAbsoluteFileIterator()) { modules.push({ dependencies: this.resolve(file, options), file,