Skip to content

Commit

Permalink
Remove babel-polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee committed Jan 30, 2017
1 parent d236e41 commit ab40e3b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion examples/async/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"devDependencies": {
"babel-jest": "*",
"babel-plugin-transform-async-to-generator": "^6.5.0",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"jest": "*"
},
Expand Down
1 change: 0 additions & 1 deletion examples/enzyme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
},
"devDependencies": {
"babel-jest": "*",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"babel-preset-react": "*",
"enzyme": "~2.4.1",
Expand Down
1 change: 0 additions & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
},
"devDependencies": {
"babel-jest": "*",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"babel-preset-react": "*",
"jest": "*",
Expand Down
1 change: 0 additions & 1 deletion examples/snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
},
"devDependencies": {
"babel-jest": "*",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"babel-preset-react": "*",
"jest": "*",
Expand Down
26 changes: 5 additions & 21 deletions packages/jest-config/src/__tests__/normalize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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`, () => {
Expand All @@ -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 = '<rootDir>' + 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();
});
Expand Down
12 changes: 1 addition & 11 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 || [])
Expand Down

0 comments on commit ab40e3b

Please sign in to comment.