Skip to content

Commit

Permalink
Fix should_instrument decision when given negative testMatch pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
g-harel committed Oct 15, 2018
1 parent 3157c8a commit f0a8fab
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- `[jest-config]` Moved dynamically assigned `cwd` from `jest-cli` to default configuration in `jest-config` ([#7146](https://github.com/facebook/jest/pull/7146))
- `[jest-config]` Fix `getMaxWorkers` on termux ([#7154](https://github.com/facebook/jest/pull/7154))
- `[jest-runtime]` Throw an explicit error if `js` is missing from `moduleFileExtensions` ([#7160](https://github.com/facebook/jest/pull/7160))
- `[jest-runtime]` Fix missing coverage when using negative glob pattern in `testMatch` ([#7170](https://github.com/facebook/jest/pull/7170))

### Chore & Maintenance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ describe('should_instrument', () => {

it('when testMatch is provided and file is not a test file', () => {
testShouldInstrument('source_file.js', defaultOptions, {
testMatch: ['**/?(*.)(test).js'],
testMatch: ['**/?(*.)(test).js', '!**/dont/**/*.js'],
});
});

it('should return true when file is in collectCoverageOnlyFrom when provided', () => {
testShouldInstrument(
'collect/only/from/here.js',

{
collectCoverage: true,
collectCoverageOnlyFrom: {'collect/only/from/here.js': true},
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/should_instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function shouldInstrument(
if (
config.testMatch &&
config.testMatch.length &&
micromatch.any(filename, config.testMatch)
micromatch([filename], config.testMatch).length
) {
return false;
}
Expand Down

0 comments on commit f0a8fab

Please sign in to comment.