Skip to content

Commit

Permalink
Merge pull request #61 from BnayaZil/fix/jest_cli_as_jest_dependency
Browse files Browse the repository at this point in the history
Consider jest-cli as jest dependency
  • Loading branch information
noahlemen authored Apr 9, 2018
2 parents b8fe64b + d05c67d commit 00c5c2f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
14 changes: 14 additions & 0 deletions __tests__/__snapshots__/packageData.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions __tests__/packageData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
});
9 changes: 9 additions & 0 deletions fixtures/jest-cli.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/upgradeDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 00c5c2f

Please sign in to comment.