Permalink
Browse files

Meta tweaks

Use tab indentation
  • Loading branch information...
sindresorhus committed Jun 26, 2017
1 parent f507e36 commit 589489db04128f9287de44e600175b4af5a2f52d
View
@@ -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"]
}
}
}
```
@@ -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"
]
}
}
```
@@ -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"]
}
}
```
@@ -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"
]
}
}
```
@@ -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"
]
}
}
```
@@ -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"]
}
}
}
```
@@ -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"
]
}
}
```
@@ -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}"
]
}
```
@@ -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"]
}
```
@@ -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"
]
}
}
```
@@ -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'));
View
@@ -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"]
}
}
```
View
@@ -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"
}
}
```
@@ -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');
});
```
@@ -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'
});
```
View
@@ -16,9 +16,9 @@ If you've configured it in your `package.json` like this:
```json
{
"scripts": {
"test": "ava"
}
"scripts": {
"test": "ava"
}
}
```
@@ -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"
}
}
```
@@ -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
}
}
```
View
20 license
@@ -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.
Oops, something went wrong.

0 comments on commit 589489d

Please sign in to comment.