I see that Nuxt.js comes already with e2e tests setup.
However, for my project I would like also to implement Karma Mocha and Chai to write unit tests for my components and for the Vuex store.
Someone has any suggestion on how to go about it ?
Is there any plan to integrate unit tests in the nuxt.config.js in the future ?
Thanks for the wonderful work by the way, Nuxt is fantastic!
I would love to see some examples as well
Not exactly karma-mocha-chai, but here's how I configured jest and puppeteer for nuxt, maybe it'll help: https://github.com/studbits/nuxt-jest-puppeteer
Hi @alidcastano, awesome! Thanks for pointing this out, I'll try this
The official VueJS test framework vue-test-utils is using mocha-webpack, where you can specify a webpack-config file. I'm now trying to get Mocha working in Nuxt using vue-test-utils... Does Nuxt expose its generated Webpack config?
mocha-webpack --webpack-config mocha-webpack.config.js --require test/_helpers/mocha-setup.js test/unit/**/*.spec.js
Should I use dllWebpackConfig from the Nuxt core? Or do I need to use a hook on the Builder class? I'm kinda lost...
(I expect to get an object with all Webpack configurations)
Edit: also vue-styleguidist requires a Webpack config.
Edit (03/03): I got it working by creating a mocha-webpack.conf.js file with the stuff I need from Nuxt, but I prefer to see something from Nuxt itself.
@PMK is it possible for you to share the content of mocha-webpack.config.js and mocha-setup.js? I am a bit lost with stuff like babel and some recent Javascript syntax that I am not able to make mocha work with vue.js and nuxt.js.
@tappoz Sure, check this Gist: https://gist.github.com/PMK/27063172a2d0e6d5b1aa2a1ba3308b79
@pi0 @Atinux any answer to @PMK question in regards to getting an export of nuxt's webpack.config? Maybe expose it as part of the /dist folder as it builds?
Not right now, but I plan to be able to get programmatically the webpack config so it could be plugged into any testing tool that need the Webpack config.
looking forward to it!
+1 for this
Resolved by #4163 and #4116. For e2e: https://github.com/melrefaie/nuxt-cypress
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@tappoz Sure, check this Gist: https://gist.github.com/PMK/27063172a2d0e6d5b1aa2a1ba3308b79