forked from mad-eye/meteor-mocha-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
54 lines (47 loc) · 1.77 KB
/
client.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
ddpParentConnection = null;
window.mochaWebClientTestsComplete = false;
var testSetupFunctions = [];
MochaWeb.testOnly = function(callback){
testSetupFunctions.push(callback);
};
window.MirrorURLs = new Meteor.Collection("mirrorUrls");
window.chai = Package['practicalmeteor:chai'].chai;
Meteor.startup(function(){
//TODO this method should probably live in the Velocity namespace velocity/mirrorInfo?
Meteor.call("mirrorInfo", function(error, mirrorInfo){
if (mirrorInfo.isMirror){
Session.set("mochaWebMirror", true);
Meteor.setTimeout(function(){
ddpParentConnection = DDP.connect(mirrorInfo.parentUrl);
ddpParentConnection.call("velocity/reports/reset", {framework: 'mocha'}, function(err, result){
// enable stack trace with line numbers with assertions
chai.config.includeStack = true;
//TODO allow ui to be customized with Meteor.settings
mocha.setup({reporter: MochaWeb.MeteorCollectionTestReporter, ui: "bdd"});
testSetupFunctions.forEach(function(testFunction){
testFunction();
});
mocha.run(function(){
window.mochaWebClientTestsComplete = true;
Meteor.call("clientTestsComplete", function(err, result){
if (err){
console.error("ERROR INVOKING CLIENT TESTS COMPLETE", err);
}
});
});
});
}, 0);
} else {
Session.set("mochaWebMirror", false);
}
});
});
Template.mochaweb.helpers({
mochaWebIFrameURL: function(){
var mirror = VelocityMirrors.findOne({framework: "mocha", state: "ready"});
if (mirror && mirror.rootUrl){
return mirror.rootUrl + mirror.rootUrlPath + "&lastModified=" + mirror.lastModified;
}
return null;
}
});