ava: SyntaxError: Unexpected token import

Using rweng, my solution came out a bit simpler.

  1. .babelrc
{
  "presets": [
    "es2015"
  ],
  "plugins": [
    "transform-runtime"
  ]
}
  1. package.json:
"ava": {
  "require": ["babel-register"],
  "babel": "inherit"
}

AVA only transpile the test files. Not test dependencies so you will need to setup babel in your project (I suppose you did it because you're using ES6 anyway).

Then in AVA's setting, add this :

"ava": {
  ...
  "babel": "inherit"
}

It means that use your project babel setting to transpile the test dependencies. See more information in AVA docs: https://github.com/sindresorhus/ava/blob/master/docs/recipes/babelrc.md

Tags:

Ava