Moved common files into karma.common.conf.js.
This commit is contained in:
@@ -7,19 +7,14 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
libraryFiles: [
|
||||
{pattern: 'common/js/vendor/**/*.js'},
|
||||
{pattern: 'edx-pattern-library/js/**/*.js'},
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/coffee/src/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/src/xmodule.js'}
|
||||
],
|
||||
var options = {
|
||||
|
||||
includeCommonFiles: true,
|
||||
|
||||
libraryFiles: [],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'coffee/src/**/!(*spec).js'},
|
||||
{pattern: 'common/js/**/!(*spec).js'},
|
||||
{pattern: 'js/**/!(*spec|djangojs).js'}
|
||||
],
|
||||
|
||||
@@ -31,7 +26,6 @@ var files = {
|
||||
|
||||
fixtureFiles: [
|
||||
{pattern: 'coffee/fixtures/**/*.underscore'},
|
||||
{pattern: 'common/templates/**/*.underscore'},
|
||||
{pattern: 'templates/**/*.underscore'}
|
||||
],
|
||||
|
||||
@@ -41,8 +35,5 @@ var files = {
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
@@ -7,19 +7,14 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
libraryFiles: [
|
||||
{pattern: 'common/js/vendor/**/*.js'},
|
||||
{pattern: 'edx-pattern-library/js/**/*.js'},
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/coffee/src/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/src/**/*.js'}
|
||||
],
|
||||
var options = {
|
||||
|
||||
includeCommonFiles: true,
|
||||
|
||||
libraryFiles: [],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'coffee/src/**/!(*spec).js'},
|
||||
{pattern: 'common/js/**/!(*spec).js'},
|
||||
{pattern: 'js/**/!(*spec|djangojs).js'}
|
||||
],
|
||||
|
||||
@@ -30,7 +25,6 @@ var files = {
|
||||
|
||||
fixtureFiles: [
|
||||
{pattern: 'coffee/fixtures/**/*.*'},
|
||||
{pattern: 'common/templates/**/*.*'},
|
||||
{pattern: 'templates/**/*.*'}
|
||||
],
|
||||
|
||||
@@ -40,8 +34,5 @@ var files = {
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, 'common_static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
var options = {
|
||||
|
||||
useRequireJs: false,
|
||||
|
||||
normalizePathsForCoverageFunc: function(appRoot, pattern) {
|
||||
return pattern;
|
||||
},
|
||||
|
||||
libraryFilesToInclude: [
|
||||
{pattern: 'common_static/js/vendor/requirejs/require.js', included: true},
|
||||
{pattern: 'RequireJS-namespace-undefine.js', included: true},
|
||||
@@ -68,10 +75,5 @@ var files = {
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files,
|
||||
normalizePathsForCoverageFunc: function(appRoot, pattern) { return pattern; },
|
||||
useRequireJs: false
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
@@ -29,6 +29,30 @@ var path = require('path');
|
||||
var _ = require('underscore');
|
||||
var appRoot = path.join(__dirname, '../../../../');
|
||||
|
||||
var commonFiles = {
|
||||
libraryFiles: [
|
||||
{pattern: 'common/js/vendor/**/*.js'},
|
||||
{pattern: 'edx-pattern-library/js/**/*.js'},
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/coffee/src/**/!(*spec).js'},
|
||||
{pattern: 'xmodule_js/common_static/js/**/!(*spec).js'},
|
||||
{pattern: 'xmodule_js/src/**/*.js'}
|
||||
],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'common/js/components/**/*.js'},
|
||||
{pattern: 'common/js/utils/**/*.js'}
|
||||
],
|
||||
|
||||
specFiles: [
|
||||
{pattern: 'common/js/spec_helpers/**/*.js'}
|
||||
],
|
||||
|
||||
fixtureFiles: [
|
||||
{pattern: 'common/templates/**/*.underscore'}
|
||||
]
|
||||
};
|
||||
|
||||
/**
|
||||
* Customize the name attribute in xml testcase element
|
||||
* @param {Object} browser
|
||||
@@ -290,14 +314,20 @@ var getBaseConfig = function (config, useRequireJs) {
|
||||
};
|
||||
};
|
||||
|
||||
var configure = function(data) {
|
||||
var useRequireJs = data.useRequireJs === undefined ? true : useRequireJs,
|
||||
baseConfig = getBaseConfig(data.config, useRequireJs);
|
||||
var configure = function(config, options) {
|
||||
var useRequireJs = options.useRequireJs === undefined ? true : useRequireJs,
|
||||
baseConfig = getBaseConfig(config, useRequireJs);
|
||||
|
||||
if (options.includeCommonFiles) {
|
||||
_.forEach(['libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles'], function (collectionName) {
|
||||
options[collectionName] = _.flatten([commonFiles[collectionName], options[collectionName]]);
|
||||
});
|
||||
}
|
||||
|
||||
var files = _.flatten(
|
||||
_.map(
|
||||
['libraryFilesToInclude', 'libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles', 'runFiles'],
|
||||
function(item) { return data.files[item] || []; }
|
||||
function(collectionName) { return options[collectionName] || []; }
|
||||
)
|
||||
);
|
||||
|
||||
@@ -314,22 +344,22 @@ var configure = function(data) {
|
||||
// With nocache=true, Karma always serves the latest files from disk.
|
||||
// However, that prevents coverage tracking from working.
|
||||
// So we only set it if coverage tracking is off.
|
||||
setNocache(files, !data.config.coverage);
|
||||
setNocache(files, !config.coverage);
|
||||
|
||||
var filesForCoverage = _.flatten(
|
||||
_.map(
|
||||
['sourceFiles', 'specFiles'],
|
||||
function(item) { return data.files[item]; }
|
||||
function(collectionName) { return options[collectionName]; }
|
||||
)
|
||||
);
|
||||
|
||||
var preprocessors = _.extend(
|
||||
{},
|
||||
data.preprocessors,
|
||||
normalizePathsForCoverage(filesForCoverage, data.normalizePathsForCoverageFunc)
|
||||
options.preprocessors,
|
||||
normalizePathsForCoverage(filesForCoverage, options.normalizePathsForCoverageFunc)
|
||||
);
|
||||
|
||||
data.config.set(_.extend(baseConfig, {
|
||||
config.set(_.extend(baseConfig, {
|
||||
files: files,
|
||||
preprocessors: preprocessors
|
||||
}));
|
||||
|
||||
@@ -7,7 +7,14 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
var options = {
|
||||
|
||||
useRequireJs: false,
|
||||
|
||||
normalizePathsForCoverageFunc: function (appRoot, pattern) {
|
||||
return path.join(appRoot, '/common/static/' + pattern);
|
||||
},
|
||||
|
||||
libraryFilesToInclude: [
|
||||
{pattern: 'coffee/src/ajax_prefix.js', included: true},
|
||||
{pattern: 'js/vendor/draggabilly.js', included: true},
|
||||
@@ -58,15 +65,6 @@ var files = {
|
||||
]
|
||||
};
|
||||
|
||||
var normalizePathsForCoverageFunc = function (appRoot, pattern) {
|
||||
return path.join(appRoot, '/common/static/' + pattern);
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files,
|
||||
normalizePathsForCoverageFunc: normalizePathsForCoverageFunc,
|
||||
useRequireJs: false
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
@@ -8,20 +8,22 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
var options = {
|
||||
|
||||
includeCommonFiles: true,
|
||||
|
||||
normalizePathsForCoverageFunc: function (appRoot, pattern) {
|
||||
return path.join(appRoot, '/common/static/' + pattern);
|
||||
},
|
||||
|
||||
libraryFiles: [
|
||||
{pattern: 'coffee/src/**/*.js'},
|
||||
{pattern: 'common/js/spec_helpers/**/*.js'},
|
||||
{pattern: 'common/js/vendor/**/*.js'},
|
||||
{pattern: 'js/libs/**/*.js'},
|
||||
{pattern: 'js/test/**/*.js'},
|
||||
{pattern: 'js/vendor/**/*.js'}
|
||||
],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'common/js/components/**/!(*spec).js'},
|
||||
{pattern: 'common/js/utils/**/!(*spec).js'}
|
||||
],
|
||||
sourceFiles: [],
|
||||
|
||||
specFiles: [
|
||||
{pattern: 'common/js/spec/**/*spec.js'}
|
||||
@@ -36,14 +38,6 @@ var files = {
|
||||
]
|
||||
};
|
||||
|
||||
var normalizePathsForCoverageFunc = function (appRoot, pattern) {
|
||||
return path.join(appRoot, '/common/static/' + pattern);
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files,
|
||||
normalizePathsForCoverageFunc: normalizePathsForCoverageFunc
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
var options = {
|
||||
|
||||
includeCommonFiles: true,
|
||||
|
||||
libraryFilesToInclude: [
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2.js', included: true},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/slick.core.js', included: true},
|
||||
@@ -15,34 +18,25 @@ var files = {
|
||||
],
|
||||
|
||||
libraryFiles: [
|
||||
{pattern: 'common/js/**/*.js'},
|
||||
{pattern: 'edx-pattern-library/js/**/*.js'},
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js'},
|
||||
{pattern: 'js/RequireJS-namespace-undefine.js'},
|
||||
{pattern: 'xmodule_js/common_static/coffee/src/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/src/capa/*.js'},
|
||||
{pattern: 'xmodule_js/src/video/*.js'},
|
||||
{pattern: 'xmodule_js/src/xmodule.js'}
|
||||
{pattern: 'js/RequireJS-namespace-undefine.js'}
|
||||
],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'coffee/src/**/!(*spec).js'},
|
||||
{pattern: 'js/**/!(*spec|djangojs).js'},
|
||||
{pattern: 'support/js/**/!(*spec).js'},
|
||||
{pattern: 'teams/js/**/!(*spec).js'},
|
||||
{pattern: 'xmodule_js/common_static/coffee/**/!(*spec).js'}
|
||||
{pattern: 'teams/js/**/!(*spec).js'}
|
||||
],
|
||||
|
||||
specFiles: [
|
||||
{pattern: 'js/spec/**/*spec.js'},
|
||||
{pattern: 'support/js/spec/**/*spec.js'},
|
||||
{pattern: 'teams/js/spec/**/*spec.js'}
|
||||
{pattern: 'teams/js/spec/**/*spec.js'},
|
||||
{pattern: 'xmodule_js/common_static/coffee/spec/**/*.js'}
|
||||
],
|
||||
|
||||
fixtureFiles: [
|
||||
{pattern: 'js/fixtures/**/*.html'},
|
||||
{pattern: 'common/templates/**/*.*'},
|
||||
{pattern: 'support/templates/**/*.*'},
|
||||
{pattern: 'teams/templates/**/*.*'},
|
||||
{pattern: 'templates/**/*.*'}
|
||||
@@ -54,8 +48,5 @@ var files = {
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
var path = require('path');
|
||||
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
|
||||
|
||||
var files = {
|
||||
var options = {
|
||||
|
||||
useRequireJs: false,
|
||||
includeCommonFiles: true,
|
||||
|
||||
libraryFilesToInclude: [
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: true},
|
||||
{pattern: 'js/spec/main_requirejs_coffee.js', included: true},
|
||||
@@ -40,13 +44,11 @@ var files = {
|
||||
],
|
||||
|
||||
libraryFiles: [
|
||||
{pattern: 'edx-pattern-library/js/**/*.js'},
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js'},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/**/*.js'}
|
||||
],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'coffee/src/**/*.js', included: true},
|
||||
{pattern: 'coffee/src/**/*.js', included: true}
|
||||
],
|
||||
|
||||
specFiles: [
|
||||
@@ -59,9 +61,5 @@ var files = {
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
configModule.configure({
|
||||
config: config,
|
||||
files: files,
|
||||
useRequireJs: false
|
||||
});
|
||||
configModule.configure(config, options);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user