Created
November 8, 2017 22:24
-
-
Save zhilich/eecfcc202168d28f1fdcaf12a43bdad3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
//This file is used to load ES6 unit-tests transpiled into AMD modules. | |
var __karma__; | |
var tests = []; | |
var files = {}; | |
for (var file in __karma__.files) { | |
if (__karma__.files.hasOwnProperty(file)) { | |
if (/spec\.js$/.test(file)) { | |
tests.push(file); | |
} | |
//For case-insensitive search | |
var key = file.toLowerCase(); | |
files[key] = file; | |
} | |
} | |
//Delay loading of Karma | |
__karma__.loaded = function () { }; | |
requirejs.config({ | |
// Karma serves files from '/base' | |
baseUrl: '.', | |
paths: {}, | |
shim: {}, | |
// ask Require.js to load these files (all our tests) | |
deps: tests, | |
// start test run, once Require.js is done | |
callback: function () { | |
__karma__.start(); | |
} | |
}); | |
//Normalize urls because Karma server is case-sensitive | |
var _load = require.load; | |
require.load = function (context, moduleName, url) { | |
var normalizedUrl = files[url.toLowerCase()]; | |
if (!normalizedUrl) { | |
console.error("File " + url + " is not served by Karma. Add missing files to Karma configuration in config.json. Consider mocking external module dependencies in main.ts."); | |
} | |
_load(context, moduleName, normalizedUrl); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment