avajs / awesome-ava

Awesome AVA resources
https://avajs.dev
Creative Commons Zero v1.0 Universal
346 stars 36 forks source link

@vue/cli plugin #26

Open dnlup opened 5 years ago

dnlup commented 5 years ago

I wrote a plugin to do unit testing for vue. Anyone willing to check it out and give me some feedback? Thanks.

Plugin repo.

novemberborn commented 5 years ago

Hey @dnlup, I don't know Vue but this looks useful. Happy to link to it here. Perhaps your approach would make a good improvement to our existing Vue recipe? There's also this open issue: https://github.com/avajs/ava/issues/2063

dnlup commented 5 years ago

@novemberborn Thank you, If you think this approach could be an improvement I'll be happy to contribute to the recipe, in the meantime I'll try to get some feedback from the issue you posted.

vinayakkulkarni commented 5 years ago

Vue Recipe & Nuxt Recipe needed for Ava.

vinayakkulkarni commented 5 years ago

I created a demo app with nuxt & ava with nyc for coverage.

https://github.com/vinayakkulkarni/nuxt-ava-e2e-unit-testing

dnlup commented 5 years ago

@novemberborn After some testing, I changed my approach in the plugin from compiling with webpack to use require extension hooks as shown in the recipes. I had quite some issues gluing webpack and ava (this is not a criticism to either one of the packages, I am sure it is because of something I did wrong) and at the end I was not happy with the result. As soon as I have some time I'll share these issues but in the meantime the recipes work well and I am happy with what is coming out. I am still finishing some last touches then I think I can reach the first stable version.

vinayakkulkarni commented 5 years ago

@dnlup thoughts on https://github.com/vinayakkulkarni/nuxt-ava-e2e-unit-testing

?

Rather than a package approach.. Why not provide users with a option to use that repo as source of examples for Vue & Ava.

I personally would hate to add another package in my package.json more than ava and Vue for just testing.

dnlup commented 5 years ago

@vinayakkulkarni Your repo is very useful indeed and I can see your point. Examples that the users can tweak to their needs give them a lot of freedom and I agree with that. This plugin is targeted to users that are using @vue/cli version 3 to scaffold their projects (it exposes a test:unit command for vue-cli-service as the other@vue/cli plugins do and the setup is using @vue/cli specific api), nuxt projects are not covered (because nuxt already has support for ava).

Rather than a package approach.. Why not provide users with a option to use that repo as source of examples for Vue & Ava.

My goal was to make something like @vue/cli-plugin-unit-mocha and @vue/cli-plugin-unit-jest but I like that too, I think could help wtih it.

I personally would hate to add another package in my package.json more than ava and Vue for just testing

I understand. If you are not using @vue/cli version 3 you should not use this but to be fair I am actually injecting the same devDependencies in a project as the one in your repo besides a couple more to load styles too (which I am conflicted about keeping them or not) so there is not much difference here. In general your are actually not just using Vue & Ava but also all the require-extension-hooks packages (injected by the create-nuxt-app when initializing the project in your case), in the plugin I am trying to automate this setup using @vue/cli specific api.