From 83a33dfedfca0ad5201a6af7a746ca48159890e8 Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Tue, 28 Feb 2017 14:13:17 +0100 Subject: [PATCH 1/7] Draft fix for #727 by describing usage of babel-polyfill --- docs/recipes/babelrc.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index 39f42c053..6d507d265 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -30,6 +30,21 @@ You can override the default Babel configuration AVA uses for test transpilation } ``` +## Provide ES2015 Polyfills to your tests + +You might run into issues when relying on ES2015-features your current environment do not support. Since Ava isn't providing any polyfills per default you might want to enable them by adding `babel-polyfill` manually to the `require` section: + +```json +{ + "ava": { + "require": [ + "babel-register", + "babel-polyfill" + ] + } +} +``` + ## Transpiling Sources To transpile your sources, you will need to define a [`babel config` ](http://babeljs.io/docs/usage/babelrc/) in `package.json` or a `.babelrc` file. Also, you will need to tell AVA to load [`babel-register`](http://babeljs.io/docs/usage/require/) in every forked process, by adding it to the `require` section of your AVA config: From 2803ec39d820fd7b64872b1414f798fa23e383e5 Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Tue, 28 Feb 2017 14:15:53 +0100 Subject: [PATCH 2/7] Fix indentation --- docs/recipes/babelrc.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index 6d507d265..0b6ea3f9a 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -36,11 +36,11 @@ You might run into issues when relying on ES2015-features your current environme ```json { - "ava": { + "ava": { "require": [ - "babel-register", - "babel-polyfill" - ] + "babel-register", + "babel-polyfill" + ] } } ``` From 161b61e37ad0114d5f2a020df830ab20394b0e76 Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Wed, 8 Mar 2017 22:32:50 +0100 Subject: [PATCH 3/7] Remove ES2015 reference, elaborate description, remove babel-register --- docs/recipes/babelrc.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index 0b6ea3f9a..cafbd1e0d 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -30,15 +30,18 @@ You can override the default Babel configuration AVA uses for test transpilation } ``` -## Provide ES2015 Polyfills to your tests +## Use Babel Polyfills -You might run into issues when relying on ES2015-features your current environment do not support. Since Ava isn't providing any polyfills per default you might want to enable them by adding `babel-polyfill` manually to the `require` section: +AVA lets you write your tests using new JavaScript syntax, even on Node.js versions that otherwise wouldn't support it. However, it doesn't add or modify built-ins of your current environment. Using AVA would, for example, not provide modern features such as `Array.prototype.includes()` to an underlying NodeJ.js 4 environment. + +By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you're able to opt these features in. Note that this will modify the environment, which may influence how your program itself behaves. + +You can enable `babel-polyfill` by adding it to AVA's require options: ```json { "ava": { "require": [ - "babel-register", "babel-polyfill" ] } From 866476bd83b5ba14ee48707c97793057261edfeb Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Thu, 9 Mar 2017 11:10:53 +0100 Subject: [PATCH 4/7] Fix Typo, reformat require option, strip "itself" --- docs/recipes/babelrc.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index cafbd1e0d..57cfe2344 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -32,11 +32,11 @@ You can override the default Babel configuration AVA uses for test transpilation ## Use Babel Polyfills -AVA lets you write your tests using new JavaScript syntax, even on Node.js versions that otherwise wouldn't support it. However, it doesn't add or modify built-ins of your current environment. Using AVA would, for example, not provide modern features such as `Array.prototype.includes()` to an underlying NodeJ.js 4 environment. +AVA lets you write your tests using new JavaScript syntax, even on Node.js versions that otherwise wouldn't support it. However, it doesn't add or modify built-ins of your current environment. Using AVA would, for example, not provide modern features such as `Array.prototype.includes()` to an underlying Node.js 4 environment. -By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you're able to opt these features in. Note that this will modify the environment, which may influence how your program itself behaves. +By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you're able to opt these features in. Note that this will modify the environment, which may influence how your program behaves. -You can enable `babel-polyfill` by adding it to AVA's require options: +You can enable `babel-polyfill` by adding it to AVA's `require` option: ```json { From 3dfa5f7df07ec41405bb8cf767549e4b84942804 Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Mon, 27 Mar 2017 11:48:22 +0200 Subject: [PATCH 5/7] Draft new default transpilation behavior section --- docs/recipes/babelrc.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index 57cfe2344..d94233333 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -13,7 +13,9 @@ There are multiple options for configuring how AVA transpiles your tests using B ## AVA's default transpiler behavior -By default, AVA transpiles your tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. This is a great option for small modules where you do not desire a build step to transpile your source before deploying to `npm`. +AVA by default provides some nifty ECMAScript features, like [`async`](https://github.com/avajs/ava#async-function-support), to your test-environment. To make this possible AVA transpiles the tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. + +This is a great feature for projects where you desire to not transpile your source before deploying but enjoy using ECMAScript for writing tests. ## Customizing how AVA transpiles your tests From 35c992cf3f8483d66816dec829a586e89b71bad4 Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Mon, 3 Apr 2017 10:54:07 +0200 Subject: [PATCH 6/7] Fix style, use JavaScript over ECMAScript --- docs/recipes/babelrc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index d94233333..faf21a7c5 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -13,7 +13,7 @@ There are multiple options for configuring how AVA transpiles your tests using B ## AVA's default transpiler behavior -AVA by default provides some nifty ECMAScript features, like [`async`](https://github.com/avajs/ava#async-function-support), to your test-environment. To make this possible AVA transpiles the tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. +AVA by default provides some nifty JavaScript features, like [`async`](https://github.com/avajs/ava#async-function-support), to your test-environment. To make this possible AVA transpiles the tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. This is a great feature for projects where you desire to not transpile your source before deploying but enjoy using ECMAScript for writing tests. @@ -36,7 +36,7 @@ You can override the default Babel configuration AVA uses for test transpilation AVA lets you write your tests using new JavaScript syntax, even on Node.js versions that otherwise wouldn't support it. However, it doesn't add or modify built-ins of your current environment. Using AVA would, for example, not provide modern features such as `Array.prototype.includes()` to an underlying Node.js 4 environment. -By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you're able to opt these features in. Note that this will modify the environment, which may influence how your program behaves. +By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you can opt in to these features in. Note that this will modify the environment, which may influence how your program behaves. You can enable `babel-polyfill` by adding it to AVA's `require` option: From 8da989494421997e5fe3ad6016fa21f2a0679ea6 Mon Sep 17 00:00:00 2001 From: Florian Breisch Date: Mon, 3 Apr 2017 17:00:08 +0200 Subject: [PATCH 7/7] Rewrite the default transpiler behavior paragraph; Fix mistake --- docs/recipes/babelrc.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index faf21a7c5..b3d43fbda 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -13,9 +13,7 @@ There are multiple options for configuring how AVA transpiles your tests using B ## AVA's default transpiler behavior -AVA by default provides some nifty JavaScript features, like [`async`](https://github.com/avajs/ava#async-function-support), to your test-environment. To make this possible AVA transpiles the tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. - -This is a great feature for projects where you desire to not transpile your source before deploying but enjoy using ECMAScript for writing tests. +AVA lets you use some nifty JavaScript features, like [async functions](https://github.com/avajs/ava#async-function-support). To make this work on older Node.js versions AVA transpiles the tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. This is great for projects where you do not use Babel for your source, but do want to use the newest JavaScript features for your tests. ## Customizing how AVA transpiles your tests @@ -36,7 +34,7 @@ You can override the default Babel configuration AVA uses for test transpilation AVA lets you write your tests using new JavaScript syntax, even on Node.js versions that otherwise wouldn't support it. However, it doesn't add or modify built-ins of your current environment. Using AVA would, for example, not provide modern features such as `Array.prototype.includes()` to an underlying Node.js 4 environment. -By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you can opt in to these features in. Note that this will modify the environment, which may influence how your program behaves. +By loading [Babel's Polyfill module](https://babeljs.io/docs/usage/polyfill/) you can opt in to these features. Note that this will modify the environment, which may influence how your program behaves. You can enable `babel-polyfill` by adding it to AVA's `require` option: