Commit 4d228199 by Usman Khalid

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.
parent ea522a17
...@@ -283,6 +283,8 @@ while i < testFiles.length ...@@ -283,6 +283,8 @@ while i < testFiles.length
testFiles[i] = '/base/' + testFiles[i] + '.js' testFiles[i] = '/base/' + testFiles[i] + '.js'
i++ 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 # start test run, once Require.js is done
window.__karma__.start() window.__karma__.start()
...@@ -202,6 +202,9 @@ i = 0 ...@@ -202,6 +202,9 @@ i = 0
while i < testFiles.length while i < testFiles.length
testFiles[i] = '/base/' + testFiles[i] + '.js' testFiles[i] = '/base/' + testFiles[i] + '.js'
i++ 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 # start test run, once Require.js is done
window.__karma__.start() window.__karma__.start()
...@@ -82,7 +82,9 @@ var libraryFiles = [ ...@@ -82,7 +82,9 @@ var libraryFiles = [
{pattern: 'edx-pattern-library/js/afontgarde.js', included: false}, {pattern: 'edx-pattern-library/js/afontgarde.js', included: false},
{pattern: 'edx-pattern-library/js/edx-icons.js', included: false}, {pattern: 'edx-pattern-library/js/edx-icons.js', included: false},
{pattern: 'edx-pattern-library/js/**/*.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 // Paths to source JavaScript files
......
...@@ -68,7 +68,8 @@ var libraryFiles = [ ...@@ -68,7 +68,8 @@ var libraryFiles = [
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js', pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js',
included: false 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 // Paths to source JavaScript files
......
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
testFiles[i] = '/base/' + testFiles[i]; testFiles[i] = '/base/' + testFiles[i];
} }
require(testFiles, function () { window.requireSerial(testFiles, function () {
// start test run, once Require.js is done // start test run, once Require.js is done
window.__karma__.start(); window.__karma__.start();
}); });
......
/*
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 = [ ...@@ -46,7 +46,8 @@ var libraryFiles = [
{pattern: 'js/test/i18n.js', included: false}, {pattern: 'js/test/i18n.js', included: false},
{pattern: 'coffee/src/jquery.immediateDescendents.js', included: false}, {pattern: 'coffee/src/jquery.immediateDescendents.js', included: false},
{pattern: 'js/vendor/requirejs/text.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 // Paths to source JavaScript files
......
...@@ -770,7 +770,9 @@ ...@@ -770,7 +770,9 @@
testFiles[i] = '/base/' + testFiles[i]; 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 // start test run, once Require.js is done
window.__karma__.start(); window.__karma__.start();
}); });
......
...@@ -73,7 +73,8 @@ var libraryFiles = [ ...@@ -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.core.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/slick.grid.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-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 // Paths to source JavaScript files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment