forked from webgme/webgme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-main.js
101 lines (80 loc) · 2.79 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*globals require*/
/*jshint browser: true*/
'use strict';
var allTestFiles = [],
TEST_REGEXP = /(spec|test)\.js$/i,
pathToModule = function (path) {
return path.replace(/^\/base\//, '').replace(/\.js$/, '');
};
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
allTestFiles.push(pathToModule(file));
}
});
require.config({
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base',
paths: {
// plugin base classes
plugin: './src/plugin',
text: './src/client/lib/require/require-text/text',
// plugins
// TODO: populate plugin list dynamically based on config.json
'plugin/MinimalWorkingExample': './src/plugin/coreplugins',
'plugin/PluginForked': './test/plugin/scenarios/plugins',
executor: './src/common/executor',
blob: './src/common/blob',
common: './src/common',
js: './src/client/js',
superagent: './src/client/lib/superagent/superagent',
jszip: './src/client/bower_components/jszip/dist/jszip',
debug: './src/client/bower_components/visionmedia-debug/dist/debug',
underscore: './src/client/bower_components/underscore/underscore',
q: './src/client/bower_components/q/q',
karmatest: './test-karma',
aRtestCases: './test-karma/client/js/AutoRouter/testCases'
// external libraries used by plugins
//'ejs': './support/ejs/ejs.min',
//'xmljsonconverter': './lib/xmljsonconverter',
//'sax': './support/sax/sax',
// modules used by test cases
//'mocks': './test/mocks',
//'models': './test/models'
},
// dynamically load all test files
deps: allTestFiles,
// we have to kickoff jasmine, as it is asynchronous
callback: testServerConnection
});
function done(err, res) {
if (err) {
console.error(err);
}
window.__karma__.start();
}
function testServerConnection () {
requirejs(['superagent'], function (superagent) {
var maxTries = 50,
i = 0,
timeout = 100;
function tryToGetGmeConfig() {
console.log('Trying to get gmeConfig.json ... ', i, i * timeout / 1000);
superagent.get('/base/gmeConfig.json')
.end(function (err, res) {
if (res.status === 200) {
console.log('Got gmeConfig.json');
done();
} else {
i += 1;
if (i < maxTries) {
setTimeout(tryToGetGmeConfig, timeout);
} else {
done(err, res);
}
}
});
}
tryToGetGmeConfig();
});
}