Testing with async/await!?
Closed this issue · 2 comments
Been using create-vue-app for my first project. Complained about imports in my tests and then async/await which are pretty standard for my ava testing workflows.
import test from 'ava'
test('create environment', async t => {
// ...
t.pass()
})
$ ava test/services/environment/create-env.test.js
/Users/kristianmandrup/repos/tecla5/red-forms/test/services/environment/create-env.test.js:1
(function (exports, require, module, __filename, __dirname) { import _regeneratorRuntime from 'babel-runtime/regenerator';
^^^^^^
SyntaxError: Unexpected token import
But looking at [vue-app](https://www.npmjs.com/package/babel-preset-vue-app) preset it should have all I need included!?
I got rid off the error my patching the `package.json` configuration as follows:
"babel": {
"presets": [
"env"
],
"plugins": [
"transform-runtime"
]
},
"ava": {
"babel": "inherit",
"require": [
"./test/helpers/setup.js",
"babel-register",
"babel-polyfill"
]
},
Now the unit test [recipe](https://github.com/avajs/ava/blob/master/docs/recipes/vue.md) seems to be "turned off"?
I guess overriding with "env" preset kills it?
"presets": [
"env"
],
Please advice on how to best setup ava testing with working async/await and imports without screwing with the default setup. Now my fetch API is also complaining that `Headers` are not defined, ie. that the `browser-env` is switched off.
Thanks :)
What the exact problem you want to resolve? The default setup works pretty well for me.
You are right. Must be some screw up with my test. Went basic to default setup and ran the test it comes with. I was trying to run a services test without Vue. I hate having to add everything to a global Vue object or to have service logic in my components as it is a super anti pattern, mix of responsibilities, and means I have to pull in Vue and essentially all the Vue render/display logic in order to test data services. Will have to experiment to see how this will work. Thanks.