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 Vue.js recipe #1361

Merged
merged 1 commit into from
May 22, 2017
Merged

Conversation

blake-newman
Copy link
Contributor

@blake-newman blake-newman commented Apr 18, 2017

Fixes #1276

@sindresorhus sindresorhus changed the title [Feature] Add vue.js recipe Add Vue.js recipe Apr 18, 2017
readme.md Outdated
@@ -1158,6 +1158,7 @@ It's the [Andromeda galaxy](https://simple.wikipedia.org/wiki/Andromeda_galaxy).
- [TypeScript](docs/recipes/typescript.md)
- [Configuring Babel](docs/recipes/babelrc.md)
- [Testing React components](docs/recipes/react.md)
- [Testing Vue components](docs/recipes/vue.md)
Copy link
Member

Choose a reason for hiding this comment

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

Vue.js

@@ -0,0 +1,71 @@
# Testing Vue components
Copy link
Member

Choose a reason for hiding this comment

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

Vue.js

"require": [
"./test/helpers/setup.js"
],
},
Copy link
Member

Choose a reason for hiding this comment

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

Remove trailing commas

}
```

```js
Copy link
Member

Choose a reason for hiding this comment

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

Make it clear that this is ./test/helpers/setup.js

test('renders', t => {
const vm = new Vue(Component).$mount();
const tree = { $el: vm.$el.outerHTML };
t.snapshot(tree);
Copy link
Member

Choose a reason for hiding this comment

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

Use tab indentation

// Setup vue files to be processed by `require-extension-hooks-vue`
hooks('vue').plugin('vue').push();
// Setup vue and js files to be processed by `require-extension-hooks-babel`
hooks(['vue', 'js']).plugin('babel').push();
Copy link
Member

Choose a reason for hiding this comment

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

Would be cool if someone made all this a module, so you could just do require('ava-vue-setup'); and be done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, currently you can add more options to babel extension plugin and there will most likely be more work for vue extension plugin to support other languages (TypeScript, Pug ect). Once this is done then we could create this npm module to wrap these options to make it simplier.

For now i think this setup is relatively easy to create and at least gives users the ability to test Vue with Ava.js which is a large step forward to Vue.js testing workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a further note, it should be trivial to add support for this in https://github.com/vuejs-templates/webpack so this could be the first stepping stone.

Choose a reason for hiding this comment

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

I know I wrote the babel extension hook but I've actually stopped using it myself due to the amount of slowdown babel causes.

I instead went for manually transpiling export/import statements like this as node can already handle pretty much all of ES2015. So unless you're using cutting edge 2017 stuff you'll probably find this much faster than babel (I should probably create a package for it).

I'm aware the impact of importing babel-core in every ava process is a known issue but I'm not sure about whether people are happy to put up with it or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm perhaps this logic should sit in the ava-vue-setup as mentioned. As we can expose all this functionality with options, and maintainability for users will be reduced. Also i'd rather provide a fully functional solution for the time being. Would cause more issues to provide all that code, especially if there is an edgecase that hasn't yet been thought off, such as dynamic import statements import('a/file.js').

Copy link
Member

Choose a reason for hiding this comment

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

@blake-newman Any updates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy for this recipe to be released. Looking at adding a ava-setup-vue package. However due to the flexible nature of Vue files will need to be more customisable so you can select transpilers. Which will take a bit of time. This recipe is good fine for a standard Vue setup but not much more

Copy link
Member

Choose a reason for hiding this comment

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

Cool :)

@sindresorhus sindresorhus merged commit 532e68c into avajs:master May 22, 2017
@sindresorhus
Copy link
Member

Thanks for doing the recipe. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants