Ava: How to use Ava with Node v7.7+ native async..await

Created on 4 Apr 2017  路  9Comments  路  Source: avajs/ava

I already transitioned my web application to use Node 7.8 (V8 5.5) and therefore have native async..await available. How do I make Ava use it too instead of transform-regenerator

All 9 comments

See the ES2017 Support section of the documentation. If you already have a babel config you want applied to your test, use the babel: "inherit" option. If you want to disable babel, you could do:

"ava": {
  "babel": {
    "presets": [] 
  }
}

That supplies an empty config, which essentially tells babel to "do nothing". AVA will still add a few transforms, but nothing related to async / await.

I don't think we use transform-regenerator anymore, since we're now only targeting Node.js versions with generator support.

When Node.js 8 comes out we'll update our transforms and we'll no longer transpile async/await for those Node.js versions.

@novemberborn so which features still need to be transpiled when relying on Node 8 ? I thought moving to Node 8 removes the need for babel completely :)

@medikoo The import/export syntax: https://github.com/avajs/babel-preset-stage-4/blob/master/plugins/8.json We also use Babel in AVA itself to detect incorrect usage of t.throws(). And there will soon be more: https://github.com/avajs/babel-preset-stage-4/issues/7 JS is constantly evolving and there will always be features not even available in the latest engines.

hi all. love the project--you're doing great work.

i'd really love to dodge the transpile step _for at least my source_ s.t. debugging is less roundabout:

  • i can edit my files in the same window during the test (vs closing the transpiled src and nav'ing to my old file)
  • ...and i can use built in break points!

i _think_ this could be as simple as getting some config to babel to _ignore my stuff_. wow-wee that'd be incredible! is that something you're open to?

good news! its seem as though the system _doesn't_ transpile code if you use pure runtime goodies! woo hoo! now, i have a native debug experience in VSCode

screen shot 2017-08-11 at 4 56 44 pm

JS is constantly evolving and there will always be features not even available in the latest engines.

@sindresorhus wouldn't it be better to just use what's available natively, without compilation overhead (?) There's actually quite big cost behind that. Is it worth it? Isn't what's natively available good enough?

@medikoo tests should work across Node.js versions. We want you to be able to use the latest syntax in your tests, even if you're developing for Node.js 6 or 4.

Was this page helpful?
0 / 5 - 0 ratings