Skip to content

Instantly share code, notes, and snippets.

@subtubes-io
Last active August 29, 2015 14:07
Show Gist options
  • Save subtubes-io/204a345730b6f525af53 to your computer and use it in GitHub Desktop.
Save subtubes-io/204a345730b6f525af53 to your computer and use it in GitHub Desktop.
Sample NPM Karma Unit Test Setup
{
"name": "unittests",
"version": "0.0.0",
"authors": [
"edgarmartinez <example@example.com>"
],
"moduleType": [
"globals"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "~2.1.1",
"angular": "~1.2.25",
"angular-mocks": "~1.2.25"
}
}
// Karma configuration
// Generated on Sat Sep 27 2014 09:07:06 GMT-0700 (PDT)
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: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'src/bower_components/jquery/dist/jquery.js',
'src/bower_components/angularjs/angular.js',
'src/bower_components/angular-mocks/angular-mocks.js',
'src/partials/*.html',
'src/app.js',
'tests/*Spec.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'src/partials/*.html': ['ng-html2js']
},
ngHtml2JsPreprocessor: {
stripPrefix: 'src/'
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// 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: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
{
"name": "sample",
"version": "0.0.0",
"description": "",
"main": " ",
"directories": {
"test": "tests"
},
"dependencies": {
"karma-jasmine": "~0.1.5",
"karma-ng-html2js-preprocessor": "~0.1.0",
"karma": "~0.12.23"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment