Testing Vue on Laravel

Categories: vue, laravel, testing

tl;dr version of getting Vue unit testing starting on a Laravel app.

NPM

  1. npm install –save-dev @vue/test-utils mocha mochapack
  2. npm install –save-dev jsdom jsdom-global
  3. npm install –save-dev expect

Configuration (opininated)

  1. Add tests/Vue/setup.js
  2. Add tests/Vue/components/
  3. Add test scripts to package.json

setup.js

require('jsdom-global')()
global.expect = require('expect')

package.json

"test": "mochapack --webpack-config node_modules/laravel-mix/setup/webpack.config.js --require tests/Vue/setup.js tests/Vue/component
Next | Previous