Skip to content

Commit

Permalink
Merge Karma configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Krister Kari committed Jun 7, 2015
1 parent 111a6cc commit 83cd03f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 93 deletions.
73 changes: 5 additions & 68 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,14 @@
// Karma configuration
// Generated on Thu Feb 26 2015 23:29:38 GMT+0200 (EET)
var extend = require("lodash.assign");
var shared = require("./karma.shared.conf.js");

module.exports = function(config) {
"use strict";

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/data.js",
"../src/mode.js",
"../src/utils.js",
"../src/support.js",
"../src/elements.js",
"../src/polyfill.js",
"../src/events.js",
"../src/main.js",
"../src/module.js",
"../test/utils/*.js",
"../test/**/*.spec.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
config.set(extend(shared, {
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
"../src/**/!(support).js": ["coverage"],
"../src/*.js": ["wrap"]
},

wrapPreprocessor: {
template: "(function(global) {\n\n\"use strict\";\n\n" +
"global.placekeeper = global.placekeeper || {};\n\n" +
"<%= contents %>\n\n}(window))"
},

// optionally, configure the reporter
coverageReporter: {
dir: "../coverage/",
reporters: [
Expand All @@ -60,31 +20,8 @@ module.exports = function(config) {
}
]
},

// test results reporter to use
// possible values: "dots", "progress"
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["progress", "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: false,

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

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
browsers: ["PhantomJS"]
}));
};
30 changes: 6 additions & 24 deletions config/karma.sauce.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var extend = require("lodash.assign");
var shared = require("./karma.shared.conf.js");

module.exports = function(config) {
"use strict";

Expand Down Expand Up @@ -42,38 +45,17 @@ module.exports = function(config) {
}
};

config.set({
basePath: "",
frameworks: ["jasmine"],
config.set(extend(shared, {
captureTimeout: 120000,
browserNoActivityTimeout: 60000,
files: [
"../src/data.js",
"../src/mode.js",
"../src/utils.js",
"../src/support.js",
"../src/elements.js",
"../src/polyfill.js",
"../src/events.js",
"../src/main.js",
"../src/module.js",
"../test/utils/*.js",
"../test/**/*.spec.js"
],
preprocessors: {
"../src/*.js": ["wrap"]
},
wrapPreprocessor: {
template: "(function(global) {\n\n\"use strict\";\n\n" +
"global.placekeeper = global.placekeeper || {};\n\n" +
"<%= contents %>\n\n}(window))"
},
sauceLabs: {
testName: "HTML5 placeholder polyfill"
},
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
reporters: ["dots", "saucelabs"],
singleRun: true
});
reporters: ["dots", "saucelabs"]
}));
};
28 changes: 28 additions & 0 deletions config/karma.shared.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var sharedKarmaConfig = {
basePath: "",
frameworks: ["jasmine"],
singleRun: true,
colors: true,
autoWatch: false,
exclude: [],
files: [
"../src/data.js",
"../src/mode.js",
"../src/utils.js",
"../src/support.js",
"../src/elements.js",
"../src/polyfill.js",
"../src/events.js",
"../src/main.js",
"../src/module.js",
"../test/utils/*.js",
"../test/**/*.spec.js"
],
wrapPreprocessor: {
template: "(function(global) {\n\n\"use strict\";\n\n" +
"global.placekeeper = global.placekeeper || {};\n\n" +
"<%= contents %>\n\n}(window))"
}
};

module.exports = sharedKarmaConfig;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.2.0",
"karma-sauce-launcher": "^0.2.11",
"karma-wrap-preprocessor": "^0.1.0"
"karma-wrap-preprocessor": "^0.1.0",
"lodash.assign": "^3.2.0"
}
}

0 comments on commit 83cd03f

Please sign in to comment.