Skip to content

Commit

Permalink
Remove unnecessary framework plugins
Browse files Browse the repository at this point in the history
We were constructing a framework plugin to load sprintf-js into the
tests.  It turns out that this was always completely unnecessary, and
that there is a much simpler solution.

Change-Id: I256178c6020d8fcde228c1e49360b6cf9adedf60
  • Loading branch information
joeyparrish committed Jul 31, 2017
1 parent 6b46d49 commit 83b0652
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ module.exports = function(config) {
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [
'jasmine-ajax', 'jasmine',
'sprintf-js',
],

plugins: [
'karma-*', // default
frameworkPluginForModule('sprintf-js'),
],

// list of files / patterns to load in the browser
Expand All @@ -82,7 +80,13 @@ module.exports = function(config) {
'dist/deps.js',
'shaka-player.uncompiled.js',

// requirejs next
// sprintf module next
// Since we don't use require to load the sprintf module, this must be
// loaded before requirejs is loaded! Otherwise, it tries to use
// requirejs instead of loading directly into the window.
'node_modules/sprintf-js/src/sprintf.js',

// requirejs module next
'node_modules/requirejs/require.js',

// bootstrapping for the test suite
Expand Down Expand Up @@ -251,34 +255,6 @@ module.exports = function(config) {
}
};

// Construct framework plugins on-the-fly for arbitrary node modules.
// A call to this must be placed in the config in the 'plugins' array,
// and the module name must be added to the config in the 'frameworks' array.
function frameworkPluginForModule(name) {
// The framework injects files into the client which runs the tests.
var framework = function(files) {
// Locate the main file for the node module.
var mainFile = path.resolve(require.resolve(name));

// Add a file entry to the list of files to be served.
// This follows the same syntax as above in config.set({files: ...}).
files.unshift({
pattern: mainFile, included: true, served: true, watched: false
});
};

// The framework factory function takes one argument, which is the list of
// files from the karma config.
framework.$inject = ['config.files'];

// This is the plugin interface to register a new framework. Adding this to
// the list of plugins makes the named module available as a framework. That
// framework then injects the module into the client.
var obj = {};
obj['framework:' + name] = ['factory', framework];
return obj;
}

// Determines which launchers and customLaunchers can be used and returns an
// array of strings.
function allUsableBrowserLaunchers(config) {
Expand Down

0 comments on commit 83b0652

Please sign in to comment.