Skip to content

Instantly share code, notes, and snippets.

@taylorzane
Created January 27, 2016 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylorzane/8ac14b49e789035007c4 to your computer and use it in GitHub Desktop.
Save taylorzane/8ac14b49e789035007c4 to your computer and use it in GitHub Desktop.
Vue.js Test Suite with Mocha + Chai + Sinon + Webpack
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
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()
<html>
<body>
<div id="test"><router-view></router-view></div>
<script src="/tests/commons.js"></script>
<script src="/tests/spec.js"></script>
</body>
</html>
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