Skip to content

Commit

Permalink
chore: support wallabyjs for karma tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimr committed Apr 23, 2015
1 parent 482654c commit 104a24a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/launchers/capture_timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ CaptureTimeoutLauncher.decoratorFactory = function(timer,
};
};

CaptureTimeoutLauncher.decoratorFactory.$inject = ['timer', 'config.captureTimeout'];

module.exports = CaptureTimeoutLauncher;
3 changes: 3 additions & 0 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ var createKarmaMiddleware = function(filesPromise, serveStaticFile,
};
};

createKarmaMiddleware.$inject = ['filesPromise', 'serveStaticFile',
'config.basePath', 'config.urlRoot', 'config.client'];


// PUBLIC API
exports.create = createKarmaMiddleware;
7 changes: 5 additions & 2 deletions lib/middleware/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ var createProxyHandler = function(proxy, proxyConfig, proxyValidateSSL, urlRoot,
return middleware;
};

exports.create = function(/* config */ config, /* config.proxies */ proxies,
var createProxyHandlerFactory = function(/* config */ config, /* config.proxies */ proxies,
/* config.proxyValidateSSL */ validateSSL) {
return createProxyHandler(new httpProxy.RoutingProxy({changeOrigin: true}),
return createProxyHandler(new httpProxy.RoutingProxy({changeOrigin: true}),
proxies, validateSSL, config.urlRoot, config);
};
createProxyHandlerFactory.$inject = ['config', 'config.proxies', 'config.proxyValidateSSL'];

exports.create = createProxyHandlerFactory;
3 changes: 3 additions & 0 deletions lib/middleware/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ var createRunnerMiddleware = function(emitter, fileList, capturedBrowsers, repor
};
};

createRunnerMiddleware.$inject = ['emitter', 'fileList', 'capturedBrowsers', 'reporter', 'executor',
'config.hostname', 'config.port', 'config.urlRoot', 'config'];


// PUBLIC API
exports.create = createRunnerMiddleware;
2 changes: 2 additions & 0 deletions lib/middleware/source_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ var createSourceFilesMiddleware = function(filesPromise, serveFile,
};
};

createSourceFilesMiddleware.$inject = ['filesPromise', 'serveFile', 'config.basePath'];


// PUBLIC API
exports.create = createSourceFilesMiddleware;
2 changes: 2 additions & 0 deletions lib/web-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var createCustomHandler = function(customFileHandlers, /* config.basePath */ bas
};
};

createCustomHandler.$inject = ['customFileHandlers', 'config.basePath'];


var createWebServer = function(injector, emitter) {
var serveStaticFile = common.createServeFile(fs, path.normalize(__dirname + '/../static'));
Expand Down
49 changes: 49 additions & 0 deletions wallaby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = function () {
return {
files: [
{
pattern: 'package.json',
instrument: false
},
{
pattern: 'config.tpl.js',
instrument: false
},
'lib/**/*.js',
'test/unit/**/*.js',
'test/unit/mocha-globals.coffee'
],

tests: [
'test/unit/**/*.spec.coffee'
],

bootstrap: function (w) {
var path = require('path');
var mocha = w.testFramework;

mocha.suite.on('pre-require', function () {

// always passing wallaby.js globals to mocks.loadFile
var mocks = require('mocks');
var loadFile = mocks.loadFile;
mocks.loadFile = function (filePath, mocks, globals, mockNested) {
mocks = mocks || {};
globals = globals || {};
globals.$_$wp = global.$_$wp;
globals.$_$w = global.$_$w;
globals.$_$wf = global.$_$wf;
globals.$_$tracer = global.$_$tracer;
return loadFile(filePath, mocks, globals, mockNested);
};

// loading mocha-globals for each run
require(path.join(process.cwd(), 'test/unit/mocha-globals'));
});
},

env: {
type: 'node'
}
};
};

0 comments on commit 104a24a

Please sign in to comment.