Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "should_instrument" decision when given negative testMatch pattern #7170

Merged
merged 1 commit into from
Oct 16, 2018
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 @@ -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