mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-15 16:17:58 +00:00
adding karma testing files and hooks
This commit is contained in:
parent
4136ed5019
commit
df9c213c33
5 changed files with 152 additions and 1 deletions
|
@ -25,6 +25,7 @@ var argv = require("yargs")
|
|||
.alias("m", "component")
|
||||
.argv;
|
||||
var webserver = require("gulp-webserver");
|
||||
var KarmaServer = require("karma").Server;
|
||||
|
||||
/**
|
||||
* BUILDING
|
||||
|
@ -157,11 +158,18 @@ gulp.task("server", function(){
|
|||
/**
|
||||
* TEST RUNNER
|
||||
*/
|
||||
gulp.task("test", ["server", "collectTests"], function(){
|
||||
gulp.task("browser-test", ["server", "collectTests"], function(){
|
||||
gulp.src("../test/index.html")
|
||||
.pipe(openFile({uri: "http://localhost:3000/test"}));
|
||||
});
|
||||
|
||||
gulp.task("karma-test", function (done) {
|
||||
new KarmaServer({
|
||||
configFile: __dirname + '/karma.conf.js',
|
||||
singleRun: true
|
||||
}, done).start();
|
||||
});
|
||||
|
||||
gulp.task("collectTests", function(done){
|
||||
var tests = ["../test/*/*.js", "!../test/helper/*.js", "!../test/tests/*.js"];
|
||||
if (argv.file){
|
||||
|
|
106
gulp/karma.conf.js
Normal file
106
gulp/karma.conf.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
// Karma configuration
|
||||
// Generated on Mon Feb 01 2016 22:48:23 GMT-0500 (EST)
|
||||
|
||||
module.exports = function(config) {
|
||||
var configuration = {
|
||||
|
||||
// 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', 'requirejs'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
// '../test/helper/Test.js',
|
||||
'test/karmaTest.js',
|
||||
{pattern: 'test/*/*.js', included: false},
|
||||
{pattern: 'test/audio/*', included: false},
|
||||
{pattern: 'Tone/*/*.js', included: false},
|
||||
],
|
||||
|
||||
|
||||
// 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: {
|
||||
},
|
||||
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['progress'],
|
||||
|
||||
//plugins
|
||||
plugins : [
|
||||
'karma-mocha',
|
||||
'karma-requirejs',
|
||||
'karma-chrome-launcher',
|
||||
'karma-firefox-launcher'
|
||||
],
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
reporter: 'html', // change Karma's debug.html to the mocha web reporter
|
||||
ui: 'bdd'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 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: [],
|
||||
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity,
|
||||
|
||||
//custom launcher for travis
|
||||
customLaunchers: {
|
||||
Chrome_travis_ci: {
|
||||
base: 'Chrome',
|
||||
flags: ['--no-sandbox']
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (process.env.TRAVIS) {
|
||||
configuration.browsers = ['Chrome_travis_ci'];
|
||||
} else {
|
||||
// configuration.browsers = ['Chrome', 'Firefox'];
|
||||
configuration.browsers = ['Chrome'];
|
||||
}
|
||||
|
||||
config.set(configuration);
|
||||
};
|
|
@ -1,4 +1,8 @@
|
|||
define(["Test", "Tone/core/Buffer"], function (Test, Buffer) {
|
||||
|
||||
if (window.__karma__){
|
||||
Buffer.baseUrl = "/base/test/";
|
||||
}
|
||||
|
||||
describe("Buffer", function(){
|
||||
it ("can be created and disposed", function(){
|
||||
|
|
27
test/karmaTest.js
Normal file
27
test/karmaTest.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
var tests = [];
|
||||
for (var file in window.__karma__.files) {
|
||||
if (window.__karma__.files.hasOwnProperty(file)) {
|
||||
if (file.indexOf("/base/test/") === 0 && file.indexOf("js") !== -1 &&
|
||||
file.indexOf("karmaTest.js") === -1 && file.indexOf("helper") === -1 &&
|
||||
file.indexOf("deps") === -1) {
|
||||
tests.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requirejs.config({
|
||||
// Karma serves files from '/base'
|
||||
baseUrl: "/base/test",
|
||||
|
||||
paths: {
|
||||
"Tone" : "../Tone",
|
||||
// "deps" : "test/deps",
|
||||
"Test" : "./helper/Test"
|
||||
},
|
||||
|
||||
// ask Require.js to load these files (all our tests)
|
||||
deps: tests,
|
||||
|
||||
// start test run, once Require.js is done
|
||||
callback: window.__karma__.start
|
||||
});
|
|
@ -1,6 +1,10 @@
|
|||
define(["helper/Basic", "Tone/source/Player", "helper/Offline", "helper/SourceTests", "Tone/core/Buffer", "helper/Meter"],
|
||||
function (BasicTests, Player, Offline, SourceTests, Buffer, Meter) {
|
||||
|
||||
if (window.__karma__){
|
||||
Buffer.baseUrl = "/base/test/";
|
||||
}
|
||||
|
||||
describe("Player", function(){
|
||||
|
||||
var buffer = new Buffer();
|
||||
|
@ -101,6 +105,8 @@ define(["helper/Basic", "Tone/source/Player", "helper/Offline", "helper/SourceTe
|
|||
|
||||
context("Looping", function(){
|
||||
|
||||
this.timeout(3000);
|
||||
|
||||
it("can be set to loop", function(){
|
||||
var player = new Player();
|
||||
player.loop = true;
|
||||
|
|
Loading…
Reference in a new issue