diff --git a/README.md b/README.md index 12f736415f5c..a7df41d91621 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,14 @@ This test used `expect` and `toBe` to test that two values were exactly identica ### Using Babel -To use [Babel](http://babeljs.io/), install the `babel-jest` and `babel-polyfill` packages: +To use [Babel](http://babeljs.io/), install the `babel-jest` and `regenerator-runtime` packages: ``` -npm install --save-dev babel-jest babel-polyfill +npm install --save-dev babel-jest regenerator-runtime ``` +*Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn* + Don't forget to add a [`.babelrc`](https://babeljs.io/docs/usage/babelrc/) file in your project's root folder. For example, if you are using ES6 and [React.js](https://facebook.github.io/react/) with the [`babel-preset-es2015`](https://babeljs.io/docs/plugins/preset-es2015/) and [`babel-preset-react`](https://babeljs.io/docs/plugins/preset-react/) presets: ```js diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 75f687cff21c..0248da476ecf 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -55,12 +55,14 @@ This test used `expect` and `toBe` to test that two values were exactly identica ### Using Babel -To use [Babel](http://babeljs.io/), install the `babel-jest` and `babel-polyfill` packages: +To use [Babel](http://babeljs.io/), install the `babel-jest` and `regenerator-runtime` packages: ``` -npm install --save-dev babel-jest babel-polyfill +npm install --save-dev babel-jest regenerator-runtime ``` +*Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn* + Don't forget to add a [`.babelrc`](https://babeljs.io/docs/usage/babelrc/) file in your project's root folder. For example, if you are using ES6 and [React.js](https://facebook.github.io/react/) with the [`babel-preset-es2015`](https://babeljs.io/docs/plugins/preset-es2015/) and [`babel-preset-react`](https://babeljs.io/docs/plugins/preset-react/) presets: ```js diff --git a/examples/async/package.json b/examples/async/package.json index 23ab959bd08c..6dbdf6f21180 100644 --- a/examples/async/package.json +++ b/examples/async/package.json @@ -2,9 +2,9 @@ "devDependencies": { "babel-jest": "*", "babel-plugin-transform-async-to-generator": "^6.5.0", - "babel-polyfill": "*", "babel-preset-es2015": "*", - "jest": "*" + "jest": "*", + "regenerator-runtime": "*" }, "scripts": { "test": "jest" diff --git a/examples/enzyme/package.json b/examples/enzyme/package.json index fcbcfeea5cae..4f5b31b44cfd 100644 --- a/examples/enzyme/package.json +++ b/examples/enzyme/package.json @@ -5,12 +5,12 @@ }, "devDependencies": { "babel-jest": "*", - "babel-polyfill": "*", "babel-preset-es2015": "*", "babel-preset-react": "*", "enzyme": "~2.4.1", "jest": "*", - "react-addons-test-utils": "15.3.2" + "react-addons-test-utils": "15.3.2", + "regenerator-runtime": "*" }, "scripts": { "test": "jest" diff --git a/examples/react/package.json b/examples/react/package.json index 71ee0087f1e8..d589a67cab46 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -5,11 +5,11 @@ }, "devDependencies": { "babel-jest": "*", - "babel-polyfill": "*", "babel-preset-es2015": "*", "babel-preset-react": "*", "jest": "*", - "react-addons-test-utils": "~15.3.1" + "react-addons-test-utils": "~15.3.1", + "regenerator-runtime": "*" }, "scripts": { "test": "jest" diff --git a/examples/snapshot/package.json b/examples/snapshot/package.json index 3644041a6270..dcc008c5034e 100644 --- a/examples/snapshot/package.json +++ b/examples/snapshot/package.json @@ -4,11 +4,11 @@ }, "devDependencies": { "babel-jest": "*", - "babel-polyfill": "*", "babel-preset-es2015": "*", "babel-preset-react": "*", "jest": "*", - "react-test-renderer": "*" + "react-test-renderer": "*", + "regenerator-runtime": "*" }, "scripts": { "test": "jest" diff --git a/packages/jest-config/src/__tests__/normalize-test.js b/packages/jest-config/src/__tests__/normalize-test.js index a9babe84fde2..a9037ab2557d 100644 --- a/packages/jest-config/src/__tests__/normalize-test.js +++ b/packages/jest-config/src/__tests__/normalize-test.js @@ -492,7 +492,7 @@ describe('babel-jest', () => { expect(config.transform[0][1]) .toEqual('/node_modules' + path.sep + 'babel-jest'); expect(config.setupFiles) - .toEqual(['/node_modules' + path.sep + 'babel-polyfill']); + .toEqual(['/node_modules' + path.sep + 'regenerator-runtime/runtime']); }); it('uses babel-jest if babel-jest is explicitly specified in a custom transform config', () => { @@ -507,7 +507,7 @@ describe('babel-jest', () => { expect(config.transform[0][0]).toBe(customJSPattern); expect(config.transform[0][1]).toEqual('/node_modules/babel-jest'); expect(config.setupFiles) - .toEqual(['/node_modules' + path.sep + 'babel-polyfill']); + .toEqual(['/node_modules' + path.sep + 'regenerator-runtime/runtime']); }); it(`doesn't use babel-jest if its not available`, () => { @@ -521,7 +521,7 @@ describe('babel-jest', () => { expect(config.setupFiles).toEqual([]); }); - it('uses polyfills if babel-jest is explicitly specified', () => { + it('uses regenerator if babel-jest is explicitly specified', () => { const ROOT_DIR = '' + path.sep; const config = normalize({ @@ -534,7 +534,7 @@ describe('babel-jest', () => { }); expect(config.setupFiles) - .toEqual(['/node_modules' + path.sep + 'babel-polyfill']); + .toEqual(['/node_modules' + path.sep + 'regenerator-runtime/runtime']); }); }); diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index 2ca2218618d6..1aa5317610b0 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -366,12 +366,13 @@ function normalize(config: InitialConfig, argv: Object = {}) { }, newConfig); if (babelJest) { - const polyfillPath = Resolver.findNodeModule('babel-polyfill', { - basedir: config.rootDir, - }); + const regeneratorRuntimePath = Resolver.findNodeModule( + 'regenerator-runtime/runtime', + {basedir: config.rootDir}, + ); - if (polyfillPath) { - newConfig.setupFiles.unshift(polyfillPath); + if (regeneratorRuntimePath) { + newConfig.setupFiles.unshift(regeneratorRuntimePath); } }