-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma-shim.js
45 lines (38 loc) · 1.43 KB
/
karma-shim.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* another one monkey patch to prevent "no timestamp" error
* https://github.com/karma-runner/karma-requirejs/issues/6#issuecomment-23037725
*/
(function (global) {
var fileWithoutLeadingSlash;
// array where all spec files will be included
global.tests = [];
for (var file in global.__karma__.files) {
if (global.__karma__.files.hasOwnProperty(file)) {
// get rid of leading slash in file path - prevents "no timestamp" error
fileWithoutLeadingSlash = file.replace(/^\//, '');
global.__karma__.files[fileWithoutLeadingSlash] = global.__karma__.files[file];
delete global.__karma__.files[file];
// we get all the test files automatically and store to window.tests array
if (/spec\.js$/.test(fileWithoutLeadingSlash)) {
global.tests.push(fileWithoutLeadingSlash);
}
}
}
})(this);
require(['base/source/js/config-require'], function (config) {
// improve config
config.baseUrl = 'base/source';
config.deps = window.tests;
config.callback = window.__karma__.start;
// adapt paths to work with built app
for (var i in config.paths) {
config.paths[i] = config.paths[i].replace('../vendor', './vendor');
}
// add config for test dependencies
config.paths['angular-mocks'] = './vendor/angular-mocks/angular-mocks';
config.shim['angular-mocks'] = ['angular'];
// alias
config.paths['Source'] = './js';
// apply config to require
window.require.config(config);
});