Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
Use tab indentation
  • Loading branch information
sindresorhus committed Jun 26, 2017
1 parent f507e36 commit 589489d
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 389 deletions.
93 changes: 49 additions & 44 deletions docs/recipes/babelrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ You can override the default Babel configuration AVA uses for test transpilation

```json
{
"ava": {
"babel": {
"plugins": ["rewire"],
"presets": ["@ava/stage-4", "stage-3"]
}
}
"ava": {
"babel": {
"plugins": ["rewire"],
"presets": ["@ava/stage-4", "stage-3"]
}
}
}
```

Expand All @@ -40,11 +40,11 @@ You can enable `babel-polyfill` by adding it to AVA's `require` option:

```json
{
"ava": {
"require": [
"babel-polyfill"
]
}
"ava": {
"require": [
"babel-polyfill"
]
}
}
```

Expand All @@ -56,12 +56,12 @@ To transpile your sources, you will need to define a [`babel config` ](http://ba

```json
{
"ava": {
"require": ["babel-register"]
},
"babel": {
"presets": ["@ava/stage-4"]
}
"ava": {
"require": ["babel-register"]
},
"babel": {
"presets": ["@ava/stage-4"]
}
}
```

Expand All @@ -75,13 +75,16 @@ Using the `"inherit"` shortcut will cause your tests to be transpiled the same a

```json
{
"ava": {
"require": "babel-register",
"babel": "inherit"
},
"babel": {
"presets": ["@ava/stage-4", "react"]
}
"ava": {
"require": "babel-register",
"babel": "inherit"
},
"babel": {
"presets": [
"@ava/stage-4",
"react"
]
}
}
```

Expand All @@ -97,17 +100,20 @@ When specifying the Babel config for your tests, you can set the `babelrc` optio

```json
{
"ava": {
"require": "babel-register",
"babel": {
"babelrc": true,
"plugins": ["custom-plugin-name"],
"presets": ["custom-preset"]
}
},
"babel": {
"presets": ["@ava/stage-4", "react"]
}
"ava": {
"require": "babel-register",
"babel": {
"babelrc": true,
"plugins": ["custom-plugin-name"],
"presets": ["custom-preset"]
}
},
"babel": {
"presets": [
"@ava/stage-4",
"react"
]
}
}
```

Expand All @@ -117,21 +123,20 @@ AVA will only look for a `.babelrc` file in the same directory as the `package.j

## Extend an alternate config file.


If, for some reason, your Babel config is not specified in one of the default locations ([`.babelrc` or `package.json`](http://babeljs.io/docs/usage/babelrc/), you can set the `extends` option to the alternate config you want to use during testing.

`package.json`:

```json
{
"ava": {
"require": "babel-register",
"babel": {
"extends": "./babel-test-config.json",
"plugins": ["custom-plugin-name"],
"presets": ["custom-preset"]
}
}
"ava": {
"require": "babel-register",
"babel": {
"extends": "./babel-test-config.json",
"plugins": ["custom-plugin-name"],
"presets": ["custom-preset"]
}
}
}
```

Expand Down
10 changes: 5 additions & 5 deletions docs/recipes/browser-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Configure AVA to `require` the helper before every test file.

```json
{
"ava": {
"require": [
"./test/helpers/setup-browser-env.js"
]
}
"ava": {
"require": [
"./test/helpers/setup-browser-env.js"
]
}
}
```

Expand Down
14 changes: 7 additions & 7 deletions docs/recipes/debugging-with-vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Add following to the `configurations` object:

```json
{
"type": "node",
"request": "launch",
"name": "Run AVA test",
"program": "${workspaceRoot}/node_modules/ava/profile.js",
"args": [
"${file}"
]
"type": "node",
"request": "launch",
"name": "Run AVA test",
"program": "${workspaceRoot}/node_modules/ava/profile.js",
"args": [
"${file}"
]
}
```

Expand Down
18 changes: 9 additions & 9 deletions docs/recipes/jspm-systemjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Configure your .babelrc to work with AVA if you have not already. NOTE: You can

```json
{
"presets": ["es2015", "stage-2"]
"presets": ["es2015", "stage-2"]
}
```

Expand All @@ -32,12 +32,12 @@ You will also need to update your AVA config in package.json to use the JSPM loa

```json
{
"ava": {
"require": [
"babel-register",
"ava-jspm-loader"
]
}
"ava": {
"require": [
"babel-register",
"ava-jspm-loader"
]
}
}
```

Expand All @@ -49,8 +49,8 @@ Note that you will need to use `System.import` paths for all of your project fil

```js
import test from 'ava';
import main from 'app/main'; // maps to your JSPM config for "app/main.js"
import BigNumber from 'bignumber.js'; // in jspm_packages
import main from 'app/main'; // Maps to your JSPM config for "app/main.js"
import BigNumber from 'bignumber.js'; // In jspm_packages

function fn() {
return Promise.resolve(new BigNumber('1234567890.123456789'));
Expand Down
14 changes: 7 additions & 7 deletions docs/recipes/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ The first step is setting up Babel to transpile JSX code from the tests by addin

```json
{
"ava": {
"require": ["babel-register"],
"babel": "inherit"
},
"babel": {
"presets": ["react"]
}
"ava": {
"require": ["babel-register"],
"babel": "inherit"
},
"babel": {
"presets": ["react"]
}
}
```

Expand Down
26 changes: 12 additions & 14 deletions docs/recipes/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Add a `test` script in the `package.json` file. It will compile the project firs

```json
{
"scripts": {
"test": "tsc && ava"
}
"scripts": {
"test": "tsc && ava"
}
}
```

Expand All @@ -41,12 +41,10 @@ Create a `test.ts` file.
```ts
import test from 'ava';

async function fn() {
return Promise.resolve('foo');
}
const fn = async () => Promise.resolve('foo');

test(async (t) => {
t.is(await fn(), 'foo');
t.is(await fn(), 'foo');
});
```

Expand All @@ -58,25 +56,25 @@ By default, the type of `t.context` will be [`any`](https://www.typescriptlang.o
import * as ava from 'ava';

function contextualize<T>(getContext: () => T): ava.RegisterContextual<T> {
ava.test.beforeEach(t => {
Object.assign(t.context, getContext());
});
ava.test.beforeEach(t => {
Object.assign(t.context, getContext());
});

return ava.test;
return ava.test;
}

const test = contextualize(() => ({ foo: 'bar' }));

test.beforeEach(t => {
t.context.foo = 123; // error: Type '123' is not assignable to type 'string'
t.context.foo = 123; // error: Type '123' is not assignable to type 'string'
});

test.after.always.failing.cb.serial('very long chains are properly typed', t => {
t.context.fooo = 'a value'; // error: Property 'fooo' does not exist on type '{ foo: string }'
t.context.fooo = 'a value'; // error: Property 'fooo' does not exist on type '{ foo: string }'
});

test('an actual test', t => {
t.deepEqual(t.context.foo.map(c => c), ['b', 'a', 'r']); // error: Property 'map' does not exist on type 'string'
t.deepEqual(t.context.foo.map(c => c), ['b', 'a', 'r']); // error: Property 'map' does not exist on type 'string'
});
```

Expand Down
20 changes: 10 additions & 10 deletions docs/recipes/watch-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ If you've configured it in your `package.json` like this:

```json
{
"scripts": {
"test": "ava"
}
"scripts": {
"test": "ava"
}
}
```

Expand All @@ -32,10 +32,10 @@ You could also set up a special script:

```json
{
"scripts": {
"test": "ava",
"watch:test": "ava --watch"
}
"scripts": {
"test": "ava",
"watch:test": "ava --watch"
}
}
```

Expand All @@ -49,9 +49,9 @@ Finally you could configure AVA to *always* run in watch mode by setting the `wa

```json
{
"ava": {
"watch": true
}
"ava": {
"watch": true
}
}
```

Expand Down
20 changes: 4 additions & 16 deletions license
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 589489d

Please sign in to comment.