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 ES2015 support to CLI #23

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ var fs = require('fs');
var path = require('path');
var globby = require('globby');
var meow = require('meow');
var resolveFrom = require('resolve-from');
var updateNotifier = require('update-notifier');

try {
require(resolveFrom('.', 'babel/register'));
Copy link
Member

Choose a reason for hiding this comment

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

This should also be babel-core.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, should probably do both, in case users use plain babel.

require(resolveFrom('.', 'babel-core/register') || resolveFrom('.', 'babel/register'));

} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

} catch (err) {

require('babel/register');
}

var cli = meow({
help: [
'Usage',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
],
"dependencies": {
"async-each-series": "^1.0.0",
"babel": "^5.8.23",
Copy link
Member

Choose a reason for hiding this comment

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

Use babel-core instead. It doesn't include the Babel CLI junk. You'll need to update the require statements.

"chalk": "^1.0.0",
"claim": "^1.3.0",
"each-async": "^1.0.0",
Expand All @@ -54,6 +55,7 @@
"globby": "^2.0.0",
"meow": "^3.3.0",
"plur": "^2.0.0",
"resolve-from": "^1.0.0",
"squeak": "^1.2.0",
"update-notifier": "^0.5.0"
},
Expand Down
48 changes: 48 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,54 @@ test.serial(function (t) {
```


### Custom assertion module

You can use any assertion module instead or in addition to the one that comes with AVA, but you won't be able to use the `.plan()` method, [yet](https://github.com/sindresorhus/ava/issues/25).

```js
var assert = require('assert');

test(function (t) {
assert(true);
t.end();
});
```


### ES2015 support

You can write your tests in ES2015:

```js
test(t => {
t.ok();
Copy link
Member

Choose a reason for hiding this comment

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

t.ok(); => t.pass();

t.end();
});
```

And run it in any node version.

```sh
$ ava
```

Also you can use your local `babel` instead of built-in.

For example, package.json:

```json
{
"devDependencies": {
"ava": "^0.1.0",
"babel": "^5.8.0"
},
"scripts": {
"test": "ava"
}
}
```


## API

### test([name], body)
Expand Down