1 const TEST_REGEXP
= /test\..*\.js/;
2 const allTestFiles
= [];
3 const extraFiles
= ['/base/tests/assertions.js'];
5 Object
.keys(window
.__karma__
.files
).forEach(function (file
) {
6 if (TEST_REGEXP
.test(file
)) {
8 allTestFiles
.push(file
);
12 // Stub out mocha's start function so we can run it once we're done loading
13 mocha
.origRun
= mocha
.run
;
14 mocha
.run = function () {};
18 // Script to import all our tests
19 script
= document
.createElement("script");
20 script
.type
= "module";
22 let allModules
= allTestFiles
.concat(extraFiles
);
23 allModules
.forEach(function (file
) {
24 script
.text
+= "import \"" + file
+ "\";\n";
26 script
.text
+= "\nmocha.origRun();\n";
27 document
.body
.appendChild(script
);
29 // Fallback code for browsers that don't support modules (IE)
30 script
= document
.createElement("script");
31 script
.type
= "module";
32 script
.text
= "window._noVNC_has_module_support = true;\n";
33 document
.body
.appendChild(script
);
36 if (!window
._noVNC_has_module_support
) {
37 /* eslint-disable no-console */
39 console
.log("No module support detected. Loading fallback...");
41 /* eslint-enable no-console */
42 let loader
= document
.createElement("script");
43 loader
.src
= "base/vendor/browser-es-module-loader/dist/browser-es-module-loader.js";
44 document
.body
.appendChild(loader
);
48 setTimeout(fallback
, 500);