title: ava: SyntaxError: Unexpected token import
body: <p>So ava comes with <a href="https://github.com/sindresorhus/ava#es2015-support" rel="noreferrer">build-in ES2015 support</a>, which works fine for my actual test files. However, when I do</p>
  
  <pre><code>import {newUser, createUser, login} from './helpers/user';
  </code></pre>
  
  <p>I can't use <code>import</code> and export in the helper file, I then get:</p>
  
  <pre><code>Users/rowe/Code/fv/foxvision-api/test/api/helpers/user.js:1
  (function (exports, require, module, __filename, __dirname) { import request from 'supertest';
  
  SyntaxError: Unexpected token import
  </code></pre>
  
  <p>I have no specific babel configuration set up as for the test files it works out of the box. Can anyone explain to me why the helper dependencies are not transpiled with babel? Using <code>test/**/helpers</code> is even following <a href="https://github.com/sindresorhus/ava#cli" rel="noreferrer">ava convention</a>.</p>
  
  <p>Thanks,
  Robin</p>
  
  <p><strong>Solution</strong></p>
  
  <p>So based on <a href="https://stackoverflow.com/users/3976412/thangngoc89">thangngoc89</a>'s solution, what I did to make it work was:</p>
  
  <ol>
  <li>Add a <code>.babelrc</code> with content:</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>{
    "presets": [
      "es2015",
      "stage-2"
    ],
    "plugins": [
      "espower",
      "transform-runtime"
    ]
  }
  </code></pre>
  
  <ol start="2">
  <li>Added to <code>package.json</code>:</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>"ava": {
    "require": ["babel-register"],
    "babel": "inherit"
  }
  </code></pre>