diff --git a/__tests__/__snapshots__/packageData.test.js.snap b/__tests__/__snapshots__/packageData.test.js.snap index 7198645..b5df27c 100644 --- a/__tests__/__snapshots__/packageData.test.js.snap +++ b/__tests__/__snapshots__/packageData.test.js.snap @@ -26,6 +26,20 @@ Object { } `; +exports[`jest-cli babel-core bridge 1`] = ` +Object { + "devDependencies": Object { + "@babel/core": "7.0.0-beta.44", + "@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.44", + "@babel/preset-env": "7.0.0-beta.44", + "babel-core": "^7.0.0-bridge.0", + "babel-loader": "^8.0.0-beta.0", + "jest-cli": "22.0.0", + }, + "name": "add-@babel/core-peerDep", +} +`; + exports[`scripts 1`] = ` Object { "name": "mocha-scripts-test", diff --git a/__tests__/packageData.test.js b/__tests__/packageData.test.js index 4eb468f..ac6fd89 100644 --- a/__tests__/packageData.test.js +++ b/__tests__/packageData.test.js @@ -2,6 +2,7 @@ const { updatePackageJSON } = require('../src/'); const upgradeDeps = require('../src/upgradeDeps'); const babelCoreFixture = require('../fixtures/babel-core'); const jestFixture = require('../fixtures/jest'); +const jestCliFixture = require('../fixtures/jest-cli'); const depsFixture = require('../fixtures/deps'); const webpackV1Fixture = require('../fixtures/webpack-v1'); const depsFixtureEarlierBeta = require('../fixtures/deps-earlier-beta.json'); @@ -71,6 +72,10 @@ test('jest babel-core bridge', async () => { expect(await updatePackageJSON(jestFixture)).toMatchSnapshot(); }); +test('jest-cli babel-core bridge', async () => { + expect(await updatePackageJSON(jestCliFixture)).toMatchSnapshot(); +}); + test('webpack v1 compatibility', async () => { expect(await updatePackageJSON(webpackV1Fixture)).toMatchSnapshot(); }); diff --git a/fixtures/jest-cli.json b/fixtures/jest-cli.json new file mode 100644 index 0000000..8aa9b2d --- /dev/null +++ b/fixtures/jest-cli.json @@ -0,0 +1,9 @@ +{ + "name": "add-@babel/core-peerDep", + "devDependencies": { + "babel-loader": "^7.1.1", + "babel-plugin-transform-object-rest-spread": "^6.20.2", + "babel-preset-es2015": "^6.18.0", + "jest-cli": "22.0.0" + } +} diff --git a/readme.md b/readme.md index a9ae3a0..c4ba573 100644 --- a/readme.md +++ b/readme.md @@ -62,7 +62,7 @@ npx babel-upgrade --install } ``` -- [x] use `"babel-core": "^7.0.0-bridge-0"` if jest is a dependency ([#14](https://github.com/babel/babel-upgrade/pull/14)) +- [x] use `"babel-core": "^7.0.0-bridge-0"` if jest or jest-cli is a dependency ([#14](https://github.com/babel/babel-upgrade/pull/14)) ```diff "devDependencies": { diff --git a/src/upgradeDeps.js b/src/upgradeDeps.js index 7e3dbbf..0313cbe 100644 --- a/src/upgradeDeps.js +++ b/src/upgradeDeps.js @@ -75,7 +75,7 @@ module.exports = function upgradeDeps(dependencies, version, options = {}) { // https://github.com/babel/babel-upgrade/issues/29 // https://github.com/babel/babel-loader/issues/505 if ( - (dependencies['jest'] || (depsWebpack1 && dependencies['babel-loader'])) && + (dependencies['jest'] || dependencies['jest-cli'] || (depsWebpack1 && dependencies['babel-loader'])) && !dependencies['babel-core'] ) { dependencies['babel-core'] = '^7.0.0-bridge.0';