Skip to content

Commit

Permalink
Documentation updates
Browse files Browse the repository at this point in the history
* Fix links between the various pages
* Remove outdated recipe on precompiling with webpack
* Update Babel documentation to remove bias towards .babelrc files. Fixes #1816.
  • Loading branch information
novemberborn committed Nov 11, 2018
1 parent afe028a commit a82fee5
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 288 deletions.
4 changes: 2 additions & 2 deletions docs/08-common-pitfalls.md
Expand Up @@ -12,7 +12,7 @@ AVA currently only transpiles the tests you ask it to run, as well as test helpe

If you use Babel you can use its [require hook](https://babeljs.io/docs/usage/require/) to transpile imported modules on-the-fly. To add it, [configure it in your `package.json`](./06-configuration.md).

You can also transpile your modules in a separate process and refer to the transpiled files rather than the sources from your tests. Example [here](./recipes/precompiling-with-webpack.md).
You can also transpile your modules in a separate process and refer to the transpiled files rather than the sources from your tests.

## AVA in Docker

Expand Down Expand Up @@ -49,7 +49,7 @@ test('fetches foo', async t => {
});
```

If you're using callbacks, use [`test.cb`](https://github.com/avajs/ava#callback-support):
If you're using callbacks, use [`test.cb`](./01-writing-tests.md#callback-support):

```js
test.cb('fetches foo', t => {
Expand Down
12 changes: 7 additions & 5 deletions docs/recipes/babel.md
Expand Up @@ -27,7 +27,7 @@ You can override the default Babel configuration AVA uses for test file compilat
}
```

All `.babelrc` options are allowed inside the `testOptions` object.
All [Babel options] are allowed inside the `testOptions` object.

## Reset AVA's cache

Expand Down Expand Up @@ -60,7 +60,7 @@ See also AVA's [`extensions` option](../06-configuration.md#options).

## Make AVA skip your project's Babel options

You may not want AVA to use your project's Babel options, for example if your project is relying on Babel 6. You can set the `babelrc` option to `false`.
You may not want AVA to use your project's Babel options, for example if your project is relying on Babel 6. Set the `babelrc` and `configFile` options to `false`.

**`package.json`:**

Expand All @@ -69,7 +69,8 @@ You may not want AVA to use your project's Babel options, for example if your pr
"ava": {
"babel": {
"testOptions": {
"babelrc": false
"babelrc": false,
"configFile": false
}
}
}
Expand Down Expand Up @@ -120,8 +121,6 @@ By default AVA's stage-4 preset will convert ES module syntax to CommonJS. This
}
```

You **must** configure the preset in the `testOptions` in order to preserve the ES module syntax. AVA will still apply the preset if you configure it in other files (for instance a `.babelrc` file). This is [due to a Babel issue](https://github.com/babel/babel/issues/7920).

You'll have to use the [`esm`](https://github.com/standard-things/esm) module so that AVA can still load your test files. [See our recipe for details](./es-modules.md).

## Disable AVA's Babel pipeline
Expand Down Expand Up @@ -206,3 +205,6 @@ Now instead of requiring `@babel/register`, require `test/_register` instead.
```

Note that loading `@babel/register` in every worker process has a non-trivial performance cost. If you have lots of test files, you may want to consider using a build step to compile your sources *before* running your tests. This isn't ideal, since it complicates using AVA's watch mode, so we recommend using `@babel/register` until the performance penalty becomes too great. Setting up a precompilation step is out of scope for this document, but we recommend you check out one of the many [build systems that support Babel](http://babeljs.io/docs/setup/). There is an [issue](https://github.com/avajs/ava/issues/577) discussing ways we could make this experience better.


[Babel options]: https://babeljs.io/docs/en/options
2 changes: 1 addition & 1 deletion docs/recipes/flow.md
Expand Up @@ -41,7 +41,7 @@ test(async (t) => {
});
```

## Typing [`t.context`](https://github.com/avajs/ava#test-context)
## Typing [`t.context`](../01-writing-tests.md#test-context)

By default, the type of `t.context` will be the empty object (`{}`). AVA exposes an interface `TestInterface<Context>` which you can use to apply your own type to `t.context`. This can help you catch errors at compile-time:

Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/jspm-systemjs.md
Expand Up @@ -10,7 +10,7 @@ This recipe has only been tested with JSPM v0.17.0-beta.22, but it should work w

### Babel

Configure your .babelrc to work with AVA if you have not already. NOTE: You can keep additional configuration in your JSPM config files to override these settings during bundling and building.
Set up your Babel options to work with AVA if you have not already. NOTE: You can keep additional configuration in your JSPM config files to override these settings during bundling and building.

```
$ npm install --save-dev @babel/preset-env
Expand Down
274 changes: 0 additions & 274 deletions docs/recipes/precompiling-with-webpack.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/recipes/typescript.md
Expand Up @@ -56,7 +56,7 @@ test(async t => {
});
```

## Using [macros](https://github.com/avajs/ava#test-macros)
## Using [macros](../01-writing-tests.md#reusing-test-logic-through-macros)

In order to be able to assign the `title` property to a macro you need to type the function:

Expand Down Expand Up @@ -86,7 +86,7 @@ const macro: CbMacro = t => {
test.cb(macro);
```

## Typing [`t.context`](https://github.com/avajs/ava#test-context)
## Typing [`t.context`](../01-writing-tests.md#test-context)

By default, the type of `t.context` will be the empty object (`{}`). AVA exposes an interface `TestInterface<Context>` which you can use to apply your own type to `t.context`. This can help you catch errors at compile-time:

Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/watch-mode.md
Expand Up @@ -119,5 +119,5 @@ Watch mode is relatively new and there might be some rough edges. Please [report
[`chokidar`]: https://github.com/paulmillr/chokidar
[Install Troubleshooting]: https://github.com/paulmillr/chokidar#install-troubleshooting
[`ignore-by-default`]: https://github.com/novemberborn/ignore-by-default
[`.only` modifier]: https://github.com/avajs/ava#running-specific-tests
[config]: https://github.com/avajs/ava#configuration
[`.only` modifier]: ../01-writing-tests.md#running-specific-tests
[config]: ../06-configuration.md
1 change: 0 additions & 1 deletion readme.md
Expand Up @@ -172,7 +172,6 @@ We have a growing list of [common pitfalls](docs/08-common-pitfalls.md) you may
- [JSPM and SystemJS](docs/recipes/jspm-systemjs.md)
- [Debugging tests with Chrome DevTools](docs/recipes/debugging-with-chrome-devtools.md)
- [Debugging tests with WebStorm](docs/recipes/debugging-with-webstorm.md)
- [Precompiling source files with webpack](docs/recipes/precompiling-with-webpack.md)
- [Isolated MongoDB integration tests](docs/recipes/isolated-mongodb-integration-tests.md)
- [Testing web apps using Puppeteer](docs/recipes/puppeteer.md)

Expand Down

0 comments on commit a82fee5

Please sign in to comment.