-
Notifications
You must be signed in to change notification settings - Fork 3
/
test-main.js
44 lines (35 loc) · 1.07 KB
/
test-main.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
/**
* This is entry-point for testing with karma-runner and requirejs
* based on sinpped from: http://karma-runner.github.io/0.8/plus/RequireJS.html
*/
(function() {
var specFiles = null;
var baseUrl = '';
var requirejsCallback = null;
// if invoked in karma-runner environment
if (typeof window != 'undefined' && window.__karma__ != undefined) {
// Karma serves files from '/base'
baseUrl = '/base';
requirejsCallback = window.__karma__.start;
// looking for *_spec.js files
specFiles = [];
for (var file in window.__karma__.files) {
if (window.__karma__.files.hasOwnProperty(file)) {
if (/.*\/js\/spec\/.+_spec\.js$/.test(file)) {
specFiles.push(file);
}
}
}
}
requirejs.config({
baseUrl: baseUrl,
paths: {
'chai': 'node_modules/chai/chai',
'sinon': 'node_modules/sinon/pkg/sinon'
},
// ask Require.js to load these files (all our tests)
deps: specFiles,
// start test run, once Require.js is done
callback: requirejsCallback
});
})();