Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example using babel 7 #6983

Merged
merged 3 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
### Chore & Maintenance

- `[docs]` Fix babel-core installation instructions ([#6745](https://github.com/facebook/jest/pull/6745))
- `[examples]` add example using Babel 7 ([#6983](https://github.com/facebook/jest/pull/6983))

### Chore & Maintenance

Expand Down
4 changes: 4 additions & 0 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ yarn add --dev babel-jest babel-core regenerator-runtime
> ```bash
> yarn add --dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down
9 changes: 9 additions & 0 deletions examples/babel-7/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.

'use strict';

import {double} from '../index';

it('works with `import`', () => {
expect(double(5)).toBe(10);
});
5 changes: 5 additions & 0 deletions examples/babel-7/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
presets: ['@babel/preset-env'],
};
5 changes: 5 additions & 0 deletions examples/babel-7/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.

export function double(input) {
return input * 2;
}
15 changes: 15 additions & 0 deletions examples/babel-7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"version": "0.0.0",
"name": "example-babel-7",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
"test": "jest"
}
}
4 changes: 4 additions & 0 deletions website/versioned_docs/version-22.0/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ npm install --save-dev babel-jest babel-core regenerator-runtime
> ```bash
> npm install --save-dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down
4 changes: 4 additions & 0 deletions website/versioned_docs/version-22.1/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ npm install --save-dev babel-jest babel-core regenerator-runtime
> ```bash
> npm install --save-dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down
4 changes: 4 additions & 0 deletions website/versioned_docs/version-22.2/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ npm install --save-dev babel-jest babel-core regenerator-runtime
> ```bash
> npm install --save-dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down
4 changes: 4 additions & 0 deletions website/versioned_docs/version-22.3/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ npm install --save-dev babel-jest babel-core regenerator-runtime
> ```bash
> npm install --save-dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down
4 changes: 4 additions & 0 deletions website/versioned_docs/version-22.4/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ yarn add --dev babel-jest babel-core regenerator-runtime
> ```bash
> yarn add --dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down
4 changes: 4 additions & 0 deletions website/versioned_docs/version-23.2/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ yarn add --dev babel-jest babel-core regenerator-runtime
> ```bash
> yarn add --dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
> ```
>
> You will need to use babel.config.js in order to transpile `node_modules`. See https://babeljs.io/docs/en/next/config-files for more information.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we wrap babel.config.js with backticks for visibility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

>
> You can also see the example in the Jest repository: https://github.com/facebook/jest/tree/master/examples/babel-7

_Note: Explicitly installing `regenerator-runtime` is not needed if you use `npm` 3 or 4 or Yarn_

Expand Down