Skip to content

Commit

Permalink
Stop re-running tests when mtime has not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Nov 9, 2018
1 parent f455bab commit df7b3da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
- `[expect]` Fix toMatchObject matcher when used with `Object.create(null)` ([#7334](https://github.com/facebook/jest/pull/7334))
- `[jest-haste-map]` [**BREAKING**] Recover files correctly after haste name collisions are fixed ([#7329](https://github.com/facebook/jest/pull/7329))
- `[jest-haste-map]` Remove legacy condition for duplicate module detection ([#7333](https://github.com/facebook/jest/pull/7333))
- `[jest-haste-map]` Stop reporting files as changed when they are only accessed ([#7347](https://github.com/facebook/jest/pull/7347))

### Chore & Maintenance

Expand Down
16 changes: 13 additions & 3 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,19 @@ class HasteMap extends EventEmitter {
return;
}

const relativeFilePath = fastPath.relative(rootDir, filePath);
const fileMetadata = hasteMap.files.get(relativeFilePath);

// The file has been accessed, not modified
if (
fileMetadata &&
type === 'change' &&
stat &&
fileMetadata[H.MTIME] === stat.mtime.getTime()
) {
return;
}

changeQueue = changeQueue
.then(() => {
// If we get duplicate events for the same file, ignore them.
Expand Down Expand Up @@ -830,9 +843,6 @@ class HasteMap extends EventEmitter {

const add = () => eventsQueue.push({filePath, stat, type});

const relativeFilePath = fastPath.relative(rootDir, filePath);
const fileMetadata = hasteMap.files.get(relativeFilePath);

// If it's not an addition, delete the file and all its metadata
if (fileMetadata != null) {
const moduleName = fileMetadata[H.ID];
Expand Down

0 comments on commit df7b3da

Please sign in to comment.