-
Notifications
You must be signed in to change notification settings - Fork 12
/
phantom.js
63 lines (48 loc) · 1.15 KB
/
phantom.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
/*jshint browser:true */
/*global hiro:false, console:false, $:false */
(function () {
"use strict";
if (!window.haunted)
return;
// Wraps a Hiro listener and sends its return value
// to the console for PhantomJS to receive.
function bind(name, callback) {
callback = callback || function () { return {}; };
hiro.bind(name, function () {
console.log(JSON.stringify({
eventName: name,
data: callback.apply({}, arguments)
}));
});
}
// Hiro events
bind("hiro.onStart");
bind("hiro.onComplete");
// Suite specific events
bind("suite.onSetup", function (suite) {
return { name: suite.name };
});
bind("suite.onStart", function (suite) {
return { name: suite.name };
});
bind("suite.onComplete", function (suite, success) {
return { name: suite.name, success: success };
});
// Test specific events
bind("test.onStart", function (test) {
return { name: test.toString() };
});
bind("test.onComplete", function (test, success, report) {
if (!success) {
return {
name: test.name,
success: false,
report: report
};
}
return {
name: test.toString(),
success: true
};
});
})();