Tone.js/scripts/karma.conf.js

159 lines
4 KiB
JavaScript
Raw Normal View History

2016-03-04 21:25:44 +00:00
// Karma configuration
2019-04-12 14:37:47 +00:00
const path = require("path");
const argv = require("yargs")
.option("grep", {
default: "",
})
.argv;
2016-03-04 21:25:44 +00:00
2019-04-12 14:37:47 +00:00
let BROWSERS = ["HeadlessChrome", "HeadlessFirefox", "Safari"];
2018-01-16 16:04:47 +00:00
2019-04-12 14:37:47 +00:00
if (process.env.BROWSER === "chrome") {
2018-01-16 16:04:47 +00:00
BROWSERS = ["HeadlessChrome"];
2019-04-12 14:37:47 +00:00
} else if (process.env.BROWSER === "firefox") {
2018-01-16 16:04:47 +00:00
BROWSERS = ["HeadlessFirefox"];
2019-04-12 14:37:47 +00:00
} else if (process.env.BROWSER === "safari") {
2018-01-16 16:04:47 +00:00
BROWSERS = ["Safari"];
2018-05-18 16:12:50 +00:00
} else {
2018-05-28 22:02:04 +00:00
BROWSERS = ["HeadlessChrome", "HeadlessFirefox"];
}
2019-04-12 14:37:47 +00:00
module.exports = function(config) {
const 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
2019-04-12 14:37:47 +00:00
frameworks : ["mocha", "karma-typescript"],
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 : [
2019-04-12 14:37:47 +00:00
"test/**/*.ts",
"Tone/**/*.ts",
{ pattern : "test/audio/**", included : false },
{ pattern : "test/html/**", included : false },
2018-01-16 16:04:47 +00:00
],
2016-03-04 21:25:44 +00:00
2019-04-12 14:37:47 +00:00
// Karma Typescript compiler options
karmaTypescriptConfig: {
compilerOptions : {
2019-07-25 18:54:02 +00:00
module: "commonjs",
2019-04-12 14:37:47 +00:00
},
bundlerOptions: {
resolve: {
directories: ["Tone", "node_modules", "test"],
},
},
coverageOptions : {
2019-08-02 20:40:50 +00:00
exclude: /(.*\.test\.ts|test\/.*\.ts)$/i,
2019-04-12 14:37:47 +00:00
},
reports: {
html: path.resolve(__dirname, "../coverage"),
2019-06-19 22:06:42 +00:00
lcovonly: {
directory : path.resolve(__dirname, "../coverage"),
filename: "coverage.lcov",
},
2019-04-12 14:37:47 +00:00
},
tsconfig: "./tsconfig.json",
},
2017-03-26 18:51:25 +00:00
// list of files to exclude
2019-04-12 14:37:47 +00:00
exclude : [
"node_modules/*",
],
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
2019-04-12 14:37:47 +00:00
preprocessors: {
"**/*.ts": "karma-typescript",
// "Tone/**/*.ts": "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
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
2019-04-12 14:37:47 +00:00
reporters : ["dots", "karma-typescript"],
2017-04-30 17:02:35 +00:00
2019-04-12 14:37:47 +00:00
// coverageReporter : {
// type : "lcov",
// dir: path.resolve(__dirname, "../coverage"),
// },
2016-03-04 21:25:44 +00:00
2017-03-26 18:51:25 +00:00
//plugins
plugins : [
2019-04-12 14:37:47 +00:00
"karma-typescript",
// "karma-coverage",
2018-01-16 16:04:47 +00:00
"karma-mocha",
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-safari-launcher",
2019-04-12 14:37:47 +00:00
// "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 : {
grep: argv.grep,
reporter : "html",
timeout : 10000,
2019-04-12 14:37:47 +00:00
ui : "bdd",
},
},
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
2019-04-12 14:37: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,
2018-05-28 22:02:04 +00:00
// restartOnFileChange : true,
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",
2019-04-12 14:37:47 +00:00
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 : {
2019-04-12 14:37:47 +00:00
"focusmanager.testmode" : true,
2018-05-18 16:12:50 +00:00
"media.navigator.permission.disabled" : true,
2019-04-12 14:37:47 +00:00
},
},
OnlineChrome: {
base: "Chrome",
flags: ["--no-sandbox", "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream",
"--autoplay-policy=no-user-gesture-required"],
},
2019-04-12 14:37:47 +00:00
},
2017-03-26 18:51:25 +00:00
};
config.set(configuration);
2016-03-04 21:25:44 +00:00
};