From ab40e3b9e3634c0885d5db253b345ccfd95f15c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Sun, 29 Jan 2017 00:28:41 +0100 Subject: [PATCH] Remove babel-polyfill --- README.md | 4 +-- docs/GettingStarted.md | 4 +-- examples/async/package.json | 1 - examples/enzyme/package.json | 1 - examples/react/package.json | 1 - examples/snapshot/package.json | 1 - .../src/__tests__/normalize-test.js | 26 ++++--------------- packages/jest-config/src/normalize.js | 12 +-------- 8 files changed, 10 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 5d7e04d099b7..68503938ecca 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,10 @@ 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` package: ``` -npm install --save-dev babel-jest babel-polyfill +npm install --save-dev babel-jest ``` 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: diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 481c3b33726f..790bcb4c3ecb 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -55,10 +55,10 @@ 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` package: ``` -npm install --save-dev babel-jest babel-polyfill +npm install --save-dev babel-jest ``` 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: diff --git a/examples/async/package.json b/examples/async/package.json index 23ab959bd08c..24e0a5bd3125 100644 --- a/examples/async/package.json +++ b/examples/async/package.json @@ -2,7 +2,6 @@ "devDependencies": { "babel-jest": "*", "babel-plugin-transform-async-to-generator": "^6.5.0", - "babel-polyfill": "*", "babel-preset-es2015": "*", "jest": "*" }, diff --git a/examples/enzyme/package.json b/examples/enzyme/package.json index fcbcfeea5cae..89bd25409a06 100644 --- a/examples/enzyme/package.json +++ b/examples/enzyme/package.json @@ -5,7 +5,6 @@ }, "devDependencies": { "babel-jest": "*", - "babel-polyfill": "*", "babel-preset-es2015": "*", "babel-preset-react": "*", "enzyme": "~2.4.1", diff --git a/examples/react/package.json b/examples/react/package.json index 71ee0087f1e8..cdec45ae9f72 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -5,7 +5,6 @@ }, "devDependencies": { "babel-jest": "*", - "babel-polyfill": "*", "babel-preset-es2015": "*", "babel-preset-react": "*", "jest": "*", diff --git a/examples/snapshot/package.json b/examples/snapshot/package.json index 3644041a6270..c69a81e54039 100644 --- a/examples/snapshot/package.json +++ b/examples/snapshot/package.json @@ -4,7 +4,6 @@ }, "devDependencies": { "babel-jest": "*", - "babel-polyfill": "*", "babel-preset-es2015": "*", "babel-preset-react": "*", "jest": "*", diff --git a/packages/jest-config/src/__tests__/normalize-test.js b/packages/jest-config/src/__tests__/normalize-test.js index e585d6206240..b41deef5667d 100644 --- a/packages/jest-config/src/__tests__/normalize-test.js +++ b/packages/jest-config/src/__tests__/normalize-test.js @@ -491,8 +491,6 @@ describe('babel-jest', () => { expect(config.transform[0][0]).toBe(DEFAULT_JS_PATTERN); expect(config.transform[0][1]) .toEqual('/node_modules' + path.sep + 'babel-jest'); - expect(config.setupFiles) - .toEqual(['/node_modules' + path.sep + 'babel-polyfill']); }); it('uses babel-jest if babel-jest is explicitly specified in a custom transform config', () => { @@ -506,8 +504,6 @@ 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']); }); it(`doesn't use babel-jest if its not available`, () => { @@ -520,29 +516,17 @@ describe('babel-jest', () => { expect(config.transform).toEqual(undefined); expect(config.setupFiles).toEqual([]); }); - - it('uses polyfills if babel-jest is explicitly specified', () => { - const ROOT_DIR = '' + path.sep; - - const config = normalize({ - rootDir: '/root', - transform: { - [DEFAULT_JS_PATTERN]: ROOT_DIR + Resolver.findNodeModule( - 'babel-jest', - ), - }, - }); - - expect(config.setupFiles) - .toEqual(['/node_modules' + path.sep + 'babel-polyfill']); - }); }); describe('Upgrade help', () => { - + let Resolver; let consoleWarn; beforeEach(() => { + Resolver = require('jest-resolve'); + Resolver.findNodeModule = jest.fn( + name => '/node_modules' + path.sep + name + ); consoleWarn = console.warn; console.warn = jest.fn(); }); diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index d57abf15cbc5..0e6bfc94af21 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -259,7 +259,7 @@ function normalize(config: InitialConfig, argv: Object = {}) { config.testEnvironment = getTestEnvironment(config); } - const babelJest = setupBabelJest(config); + setupBabelJest(config); const newConfig = Object.assign({}, DEFAULT_CONFIG); Object.keys(config).reduce((newConfig, key) => { @@ -361,16 +361,6 @@ function normalize(config: InitialConfig, argv: Object = {}) { return newConfig; }, newConfig); - if (babelJest) { - const polyfillPath = Resolver.findNodeModule('babel-polyfill', { - basedir: config.rootDir, - }); - - if (polyfillPath) { - newConfig.setupFiles.unshift(polyfillPath); - } - } - // If argv.json is set, coverageReporters shouldn't print a text report. if (argv.json) { newConfig.coverageReporters = (newConfig.coverageReporters || [])