Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- `[jest-environment-jsdom, jest-environment-node]` Fix assignment of `customExportConditions` via `testEnvironmentOptions` when custom env subclass defines a default value ([#13989](https://github.com/facebook/jest/pull/13989))
- `[jest-matcher-utils]` Fix copying value of inherited getters ([#14007](https://github.com/facebook/jest/pull/14007))
- `[jest-snapshot]` Fix a potential bug when not using prettier and improve performance ([#14036](https://github.com/facebook/jest/pull/14036))
- `[@jest/transform]` Do not instrument `.json` modules ([#14048](https://github.com/facebook/jest/pull/14048))

### Chore & Maintenance

Expand Down
14 changes: 14 additions & 0 deletions packages/jest-transform/src/__tests__/shouldInstrument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ describe('shouldInstrument', () => {
['dont/collect/coverage.js'],
);
});

it('when file is a .json module, but matches forceCoverageMatch', () => {
testShouldInstrument('do/collect/coverage.json', defaultOptions, {
forceCoverageMatch: ['**/do/**/*.json'],
});
});
});

describe('should return false', () => {
Expand Down Expand Up @@ -245,5 +251,13 @@ describe('shouldInstrument', () => {
['do/collect/coverage.js'],
);
});

it('when file is a .json module', () => {
testShouldInstrument(
'dont/collect/coverage.json',
defaultOptions,
defaultConfig,
);
});
});
});
4 changes: 4 additions & 0 deletions packages/jest-transform/src/shouldInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,9 @@ export default function shouldInstrument(
}
}

if (filename.endsWith('.json')) {
return false;
}

return true;
}