Created
November 24, 2018 16:31
-
-
Save alexrusin/329b1f388abe51c3ff05a78beacff96e to your computer and use it in GitHub Desktop.
Laravel Vue testing set up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// package.json | |
{ | |
"private": true, | |
"scripts": { | |
"dev": "npm run development", | |
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"watch": "npm run development -- --watch", | |
"watch-poll": "npm run watch -- --watch-poll", | |
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"prod": "npm run production", | |
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"test": "mocha-webpack --webpack-config=node_modules/laravel-mix/setup/webpack.config.js --require tests/JavaScript/setup.js tests/JavaScript/**/*.spec.js" | |
}, | |
"devDependencies": { | |
"@vue/test-utils": "^1.0.0-beta.25", | |
"axios": "^0.18", | |
"bootstrap": "^4.0.0", | |
"cross-env": "^5.1", | |
"expect": "^23.6.0", | |
"jquery": "^3.2", | |
"jsdom": "^13.0.0", | |
"jsdom-global": "^3.0.2", | |
"laravel-mix": "^2.0", | |
"lodash": "^4.17.5", | |
"mocha": "^4.0.1", | |
"mocha-webpack": "^0.7.0", | |
"popper.js": "^1.12", | |
"vue": "^2.5.17" | |
} | |
} | |
// tests/JavaScript/setup.js | |
require('jsdom-global')(); | |
window.Date = Date; //temp fix for prettier error | |
// may also need todisable versioning in when testing | |
"scripts": { | |
// ... | |
"test": "cross-env NODE_ENV=test mocha-webpack --webpack-config=node_modules/laravel-mix/setup/webpack.config.js --require tests/JavaScript/setup.js tests/JavaScript/**/*.spec.js" | |
} | |
// in webpack.mix.js | |
if (process.env.NODE_ENV !== 'test') { | |
mix.version(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment