Created
January 27, 2016 19:28
Vue.js Test Suite with Mocha + Chai + Sinon + Webpack
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
chai = require 'chai' | |
sinon = require 'sinon' | |
sinonChai = require 'sinon-chai' | |
expect = chai.expect | |
chai.use sinonChai | |
Async = require 'async' | |
vm = | |
new Vue | |
el: '#test' | |
describe 'Vue', -> | |
beforeEach -> | |
doSetup() | |
it 'Has a Foo instance', (done) -> | |
# $vm.components.etc |
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
gulp.task 'test:integration', (done) -> | |
testWebpack = require 'webpack' | |
webpackDevServer = require 'webpack-dev-server' | |
webpackTestConfig = require './src/webview/spec/webpack.test.config.coffee' | |
compiler = testWebpack(webpackTestConfig) | |
server = new webpackDevServer compiler, | |
contentBase: './src/webview/spec' | |
hot: true | |
historyApiFallback: false | |
quiet: false | |
noInfo: false | |
watchOptions: | |
aggregateTimeout: 300 | |
poll: 1000 | |
publicPath: '/tests/' | |
headers: 'X-Custom-Header': 'yes' | |
stats: colors: true | |
server.listen 3100, 'localhost', -> return | |
done() |
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
<html> | |
<body> | |
<div id="test"><router-view></router-view></div> | |
<script src="/tests/commons.js"></script> | |
<script src="/tests/spec.js"></script> | |
</body> | |
</html> |
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
webpack = require 'webpack' | |
path = require 'path' | |
srcDir = path.resolve __dirname, '..' | |
# Config | |
module.exports = | |
context: srcDir | |
entry: 'mocha!./spec/exampleSpec.coffee' | |
output: | |
path: '/' | |
publicPath: '/tests/' | |
filename: 'spec.js' | |
chunkFilename: 'spec.chunk.js' | |
module: | |
loaders: [ | |
test: /\.coffee$/, loader: 'coffee' | |
] | |
noParse: [ | |
/node_modules\/sinon\// | |
] | |
resolve: | |
modulesDirectories: ['src/webview', 'node_modules'] | |
extensions: ['', '.coffee', '.js'] | |
alias: | |
sinon: 'sinon/pkg/sinon.js' | |
node: | |
fs: 'empty' | |
plugins: [ | |
new webpack.ProvidePlugin | |
'Vue': 'vue/dist/vue.js' | |
new webpack.optimize.CommonsChunkPlugin('commons.js') | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment