When using RequireJS load spec files one by one.
Jasmine has a global stack for creating a tree of specs. We need to load spec files one by one, otherwise some end up getting nested under others.
This commit is contained in:
committed by
Clinton Blackburn
parent
e8c1d82a26
commit
d851b2c951
@@ -283,6 +283,8 @@ while i < testFiles.length
|
||||
testFiles[i] = '/base/' + testFiles[i] + '.js'
|
||||
i++
|
||||
|
||||
require testFiles, ->
|
||||
# Jasmine has a global stack for creating a tree of specs. We need to load
|
||||
# spec files one by one, otherwise some end up getting nested under others.
|
||||
requireSerial testFiles, ->
|
||||
# start test run, once Require.js is done
|
||||
window.__karma__.start()
|
||||
|
||||
@@ -202,6 +202,9 @@ i = 0
|
||||
while i < testFiles.length
|
||||
testFiles[i] = '/base/' + testFiles[i] + '.js'
|
||||
i++
|
||||
require testFiles, ->
|
||||
|
||||
# Jasmine has a global stack for creating a tree of specs. We need to load
|
||||
# spec files one by one, otherwise some end up getting nested under others.
|
||||
requireSerial testFiles, ->
|
||||
# start test run, once Require.js is done
|
||||
window.__karma__.start()
|
||||
|
||||
@@ -82,7 +82,9 @@ var libraryFiles = [
|
||||
{pattern: 'edx-pattern-library/js/afontgarde.js', included: false},
|
||||
{pattern: 'edx-pattern-library/js/edx-icons.js', included: false},
|
||||
{pattern: 'edx-pattern-library/js/**/*.js', included: false},
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js', included: false}
|
||||
{pattern: 'edx-ui-toolkit/js/**/*.js', included: false},
|
||||
|
||||
{pattern: 'common/js/utils/require-serial.js', included: true}
|
||||
];
|
||||
|
||||
// Paths to source JavaScript files
|
||||
|
||||
@@ -68,7 +68,8 @@ var libraryFiles = [
|
||||
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js',
|
||||
included: false
|
||||
},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/text.js', included: false}
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/text.js', included: false},
|
||||
{pattern: 'common/js/utils/require-serial.js', included: true}
|
||||
];
|
||||
|
||||
// Paths to source JavaScript files
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
testFiles[i] = '/base/' + testFiles[i];
|
||||
}
|
||||
|
||||
require(testFiles, function () {
|
||||
window.requireSerial(testFiles, function () {
|
||||
// start test run, once Require.js is done
|
||||
window.__karma__.start();
|
||||
});
|
||||
|
||||
23
common/static/common/js/utils/require-serial.js
Normal file
23
common/static/common/js/utils/require-serial.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Helper function used to require files serially instead of concurrently.
|
||||
*/
|
||||
(function (window, require) {
|
||||
'use strict';
|
||||
|
||||
var requireModules = function (paths, callback, modules) {
|
||||
// If all the modules have been loaded, call the callback.
|
||||
if (paths.length === 0) {
|
||||
return callback.apply(null, modules);
|
||||
}
|
||||
// Otherwise load the next one.
|
||||
require([paths.shift()], function(module) {
|
||||
modules.push(module);
|
||||
requireModules(paths, callback, modules);
|
||||
});
|
||||
};
|
||||
|
||||
window.requireSerial = function(paths, callback) {
|
||||
requireModules(paths, callback, []);
|
||||
};
|
||||
|
||||
}).call(this, window, require || RequireJS.require);
|
||||
@@ -46,7 +46,8 @@ var libraryFiles = [
|
||||
{pattern: 'js/test/i18n.js', included: false},
|
||||
{pattern: 'coffee/src/jquery.immediateDescendents.js', included: false},
|
||||
{pattern: 'js/vendor/requirejs/text.js', included: false},
|
||||
{pattern: 'js/vendor/sinon-1.17.0.js', included: false}
|
||||
{pattern: 'js/vendor/sinon-1.17.0.js', included: false},
|
||||
{pattern: 'common/js/utils/require-serial.js', included: true}
|
||||
];
|
||||
|
||||
// Paths to source JavaScript files
|
||||
|
||||
@@ -770,7 +770,9 @@
|
||||
testFiles[i] = '/base/' + testFiles[i];
|
||||
}
|
||||
|
||||
require(testFiles, function () {
|
||||
// Jasmine has a global stack for creating a tree of specs. We need to load
|
||||
// spec files one by one, otherwise some end up getting nested under others.
|
||||
window.requireSerial(testFiles, function () {
|
||||
// start test run, once Require.js is done
|
||||
window.__karma__.start();
|
||||
});
|
||||
|
||||
@@ -73,7 +73,8 @@ var libraryFiles = [
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/slick.core.js', included: true},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/slick.grid.js', included: true},
|
||||
{pattern: 'xmodule_js/common_static/js/libs/jasmine-waituntil.js', included: true},
|
||||
{pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true}
|
||||
{pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
|
||||
{pattern: 'common/js/utils/require-serial.js', included: true}
|
||||
];
|
||||
|
||||
// Paths to source JavaScript files
|
||||
|
||||
Reference in New Issue
Block a user