From e930c705d6d1b77f762fa65ad24eaf80d68c7b3f Mon Sep 17 00:00:00 2001 From: Tvrqvoise <5715027+Tvrqvoise@users.noreply.github.com> Date: Mon, 9 Jul 2018 15:32:15 -0500 Subject: [PATCH] Roll back micromatch (#6661) ## Summary As part of #6400, `micromatch` was updated. While `micromatch`'s CHANGELOG claims that this is safe, several regressions have been noted in cases where users relied upon invalid glob patterns. For example, these patterns would all match `src/foo/bar/baz.js`, but no longer do: - `src/**/*.{js}` - `src/**.js` - `src/**/*.{js|ts}` Fixes #6563 Fixes #6546 ## Test plan Unit tests were added which demonstrate the known cases. --- CHANGELOG.md | 1 + package.json | 2 +- packages/jest-cli/package.json | 2 +- packages/jest-haste-map/package.json | 2 +- packages/jest-message-util/package.json | 2 +- packages/jest-runtime/package.json | 2 +- .../src/__tests__/should_instrument.test.js | 16 ++++++++++++++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 409a0117f35b..502e6930fad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - `[jest-cli]` properly reprint resolver errors in watch mode ([#6407](https://github.com/facebook/jest/pull/6407)) - `[jest-cli]` Write configuration to stdout when the option was explicitly passed to Jest ([#6447](https://github.com/facebook/jest/pull/6447)) - `[jest-cli]` Fix regression on non-matching suites ([6657](https://github.com/facebook/jest/pull/6657)) +- `[jest-runtime]` Roll back `micromatch` version to prevent regression when matching files ([#6661](https://github.com/facebook/jest/pull/6661)) ## 23.3.0 diff --git a/package.json b/package.json index 719fa9c832f9..5b0f91922d07 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "karma-mocha": "^1.3.0", "left-pad": "^1.1.1", "lerna": "2.11.0", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "mkdirp": "^0.5.1", "mocha": "^5.0.1", "mock-fs": "^4.4.1", diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 15e1d8dd29de..61c527b33da5 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -30,7 +30,7 @@ "jest-validate": "^23.3.0", "jest-watcher": "^23.2.0", "jest-worker": "^23.2.0", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "node-notifier": "^5.2.1", "prompts": "^0.1.9", "realpath-native": "^1.0.0", diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index a32021cbe102..b4f8fa6b5770 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -13,7 +13,7 @@ "jest-docblock": "^23.2.0", "jest-serializer": "^23.0.1", "jest-worker": "^23.2.0", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "sane": "^2.0.0" } } diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index e44db220a513..8f3081e9a253 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -10,7 +10,7 @@ "dependencies": { "@babel/code-frame": "^7.0.0-beta.35", "chalk": "^2.0.1", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "slash": "^1.0.0", "stack-utils": "^1.0.1" } diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index b984e921ea66..5afd71a23a48 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -23,7 +23,7 @@ "jest-snapshot": "^23.3.0", "jest-util": "^23.3.0", "jest-validate": "^23.3.0", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "realpath-native": "^1.0.0", "slash": "^1.0.0", "strip-bom": "3.0.0", diff --git a/packages/jest-runtime/src/__tests__/should_instrument.test.js b/packages/jest-runtime/src/__tests__/should_instrument.test.js index 48e79734227c..f1965b05f6c6 100644 --- a/packages/jest-runtime/src/__tests__/should_instrument.test.js +++ b/packages/jest-runtime/src/__tests__/should_instrument.test.js @@ -62,6 +62,22 @@ describe('should_instrument', () => { ); }); + it('should should match invalid globs, to be removed in the next major', () => { + const testSingleCollectCoverageFrom = pattern => + testShouldInstrument( + 'do/collect/coverage.js', + { + collectCoverage: true, + collectCoverageFrom: [pattern], + }, + defaultConfig, + ); + + testSingleCollectCoverageFrom('**/do/**/*.{js}'); + testSingleCollectCoverageFrom('**/do/**/*.{js|ts}'); + testSingleCollectCoverageFrom('**/do/**.js'); + }); + it('should return true if the file is not in coveragePathIgnorePatterns', () => { testShouldInstrument('do/collect/coverage.js', defaultOptions, { coveragePathIgnorePatterns: ['dont'],