Skip to content

Commit

Permalink
add karma, karma-webpack, istanbul reporter, istanbul instrumenter, k…
Browse files Browse the repository at this point in the history
…arma-mocha
  • Loading branch information
ssreed committed Oct 10, 2017
1 parent 8ade8e4 commit 5dfe8dc
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 1 deletion.
95 changes: 95 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Karma configuration
// Generated on Tue Jul 18 2017 12:17:16 GMT-0700 (PDT)

var path = require('path');

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


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


// list of files / patterns to load in the browser
files: [
'tests/tests.webpack.js'
],


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


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


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [ 'progress', 'coverage-istanbul' ],

coverageIstanbulReporter: {
reports: [ 'lcov', 'text-summary' ],
fixWebpackSourcePaths: true
},

webpack: {
module: {
rules: [
// instrument only testing sources with Istanbul
{
test: /\.js$/,
include: path.resolve('src/'),
exclude: path.resolve(__dirname, 'node_modules'),
use: [
{
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
],
}
]
}
},

// 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: false,


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


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

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"test": "cross-env BABEL_ENV=test mocha --compilers js:babel-register --recursive tests/unit",
"testfunc": "cross-env BABEL_ENV=test mocha --compilers js:babel-register tests/functional/auto/hlsjs.js --timeout 40000",
"lint": "jshint src/",
"dev": "webpack-dev-server --env.debug --port 8000"
"dev": "webpack-dev-server --env.debug --port 8000",
"coverage": "karma start karma.conf.js"
},
"dependencies": {
"url-toolkit": "^2.0.1"
Expand All @@ -50,7 +51,13 @@
"cross-env": "^5.0.2",
"deep-strict-equal": "^0.2.0",
"http-server": "^0.10.0",
"istanbul-instrumenter-loader": "^2.0.0",
"jshint": "^2.9.4",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-mocha": "^1.3.0",
"karma-webpack": "^2.0.4",
"mocha": "^3.0.2",
"mversion": "^1.10.1",
"selenium-webdriver": "^3.1.0",
Expand Down
7 changes: 7 additions & 0 deletions tests/tests.webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const tests = require.context('./unit/', true, /\.js$/);

tests.keys().forEach(tests);

const components = require.context('../src/', true, /\.js$/);

components.keys().forEach(components);

0 comments on commit 5dfe8dc

Please sign in to comment.