Skip to content

Commit

Permalink
add vue unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yinsang committed Sep 18, 2018
1 parent c003670 commit 8ecc100
Show file tree
Hide file tree
Showing 19 changed files with 4,041 additions and 3,460 deletions.
3 changes: 0 additions & 3 deletions vue-unitTest-karma-webpack/.babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions vue-unitTest-karma-webpack/.eslintrc.js

This file was deleted.

8 changes: 4 additions & 4 deletions vue-unitTest-karma-webpack/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>vue unit test</title>
<title>Document</title>
</head>
<body>
<div id="app">{{value}}</div>
<script src="./dist/main.js"></script>
<div id="app"></div>
<script src="dist/main.js"></script>
</body>
</html>
</html>
38 changes: 22 additions & 16 deletions vue-unitTest-karma-webpack/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,68 @@
// Karma configuration
// Generated on Fri Sep 14 2018 17:50:53 GMT+0800 (GMT+08:00)
// const webpack = require('webpack')
const webpackConfig = require('./webpack.config.js')
// delete webpackConfig.entry
webpackConfig.entry = {}
module.exports = function (config) {
// Generated on Tue Sep 18 2018 16:54:37 GMT+0800 (GMT+08:00)
const webpackConfig = require('./webpack.config')
module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
webpack: webpackConfig,
vue: {
loaders: 'babel-loader'
},


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],


// list of files / patterns to load in the browser
files: [
'unit/**/*.test.js'
],
webpack:webpackConfig,


// list of files / patterns to exclude
exclude: [
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./unit/*.test.js': ['webpack']
'unit/**/*.test.js':['webpack', 'coverage']
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
reporters: ['progress', 'coverage'],
coverageReporter:{
type:'html',
dir:'./unit-coverage/'
},

// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['chrome'],
// plugins: [
// 'karma-chrome-launcher'
// ],
browsers: ['Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
Expand Down
Loading

0 comments on commit 8ecc100

Please sign in to comment.