Tone.js/gulp/karma.conf.js

142 lines
3.5 KiB
JavaScript
Raw Normal View History

2016-03-04 21:25:44 +00:00
// Karma configuration
var path = require("path");
2016-03-04 21:25:44 +00:00
2018-01-16 16:04:47 +00:00
var BROWSERS = ["HeadlessChrome", "HeadlessFirefox", "Safari"];
if (process.env.BROWSER === "chrome"){
BROWSERS = ["HeadlessChrome"];
} else if (process.env.BROWSER === "firefox"){
BROWSERS = ["HeadlessFirefox"];
} else if (process.env.BROWSER === "safari"){
BROWSERS = ["Safari"];
2018-05-18 16:12:50 +00:00
} else {
BROWSERS = ["HeadlessChrome"];
}
2018-01-16 16:04:47 +00:00
module.exports = function(config){
2017-03-26 18:51:25 +00:00
var configuration = {
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// base path that will be used to resolve all patterns (eg. files, exclude)
2018-01-16 16:04:47 +00:00
basePath : "../",
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
2018-05-18 16:12:50 +00:00
frameworks : ["mocha"],
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// list of files / patterns to load in the browser
2018-01-16 16:04:47 +00:00
files : [
2018-05-19 16:35:40 +00:00
"test/test.js",
2018-01-16 16:04:47 +00:00
{ pattern : "test/audio/*", included : false },
{ pattern : "test/audio/*/*", included : false },
2018-01-16 16:04:47 +00:00
],
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// list of files to exclude
2018-01-16 16:04:47 +00:00
exclude : [],
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
2018-01-16 16:04:47 +00:00
preprocessors : {
"test/test.js" : ["webpack", "sourcemap"],
2017-04-30 17:02:35 +00:00
},
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
2018-01-16 16:04:47 +00:00
reporters : ["dots", "coverage"],
2017-04-30 17:02:35 +00:00
2018-01-16 16:04:47 +00:00
coverageReporter : {
type : "lcov",
dir : "test/coverage/"
2017-04-30 17:02:35 +00:00
},
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
//plugins
plugins : [
2018-01-16 16:04:47 +00:00
"karma-coverage",
"karma-mocha",
"karma-webpack",
2018-01-16 16:04:47 +00:00
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-safari-launcher",
"karma-sourcemap-loader",
2017-03-26 18:51:25 +00:00
],
2016-03-04 21:25:44 +00:00
2018-01-16 16:04:47 +00:00
client : {
mocha : {
reporter : "html", // change Karma's debug.html to the mocha web reporter
ui : "bdd"
2017-03-26 18:51:25 +00:00
}
},
2016-03-04 21:25:44 +00:00
//webpack
webpack : {
mode : "development",
resolve : {
modules : [
path.resolve(__dirname, "../node_modules"),
path.resolve(__dirname, "../"),
path.resolve(__dirname, "../test")
],
},
module : {
rules : [
//enables correct coverage mapping
{
test : /\.js$/,
use : { loader : "istanbul-instrumenter-loader" },
include : path.resolve(__dirname, "../Tone"),
exclude : path.resolve(__dirname, "../Tone/shim")
}
]
},
devtool : "inline-source-map"
},
2017-03-26 18:51:25 +00:00
// web server port
2018-01-16 16:04:47 +00:00
port : 9876,
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// enable / disable colors in the output (reporters and logs)
2018-01-16 16:04:47 +00:00
colors : true,
2016-03-04 21:25:44 +00:00
// set the inactivity level to longer
2017-11-24 22:07:29 +00:00
browserNoActivityTimeout : 40000,
2017-03-26 18:51:25 +00:00
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
2018-01-16 16:04:47 +00:00
logLevel : config.LOG_ERROR,
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// enable / disable watching file and executing tests whenever any file changes
2018-01-16 16:04:47 +00:00
autoWatch : false,
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
2018-01-16 16:04:47 +00:00
browsers : BROWSERS,
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun : false,
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
// Concurrency level
// how many browser should be started simultaneous
2017-11-29 21:14:53 +00:00
// concurrency: process.env.TRAVIS ? 1 : Infinity,
2018-01-16 16:04:47 +00:00
concurrency : Infinity,
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
//custom launcher for travis
2018-01-16 16:04:47 +00:00
customLaunchers : {
HeadlessChrome : {
base : "ChromeHeadless",
flags : ["--no-sandbox", "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--autoplay-policy=no-user-gesture-required"]
2017-10-26 18:11:47 +00:00
},
2018-01-16 16:04:47 +00:00
HeadlessFirefox : {
2018-05-18 16:12:50 +00:00
base : "Firefox",
2018-01-16 16:04:47 +00:00
flags : ["-headless"],
2018-05-18 16:12:50 +00:00
prefs : {
"media.navigator.permission.disabled" : true,
2018-01-16 16:04:47 +00:00
"focusmanager.testmode" : true
2018-05-18 16:12:50 +00:00
}
}
2017-03-26 18:51:25 +00:00
}
};
config.set(configuration);
2016-03-04 21:25:44 +00:00
};