This repository was archived by the owner on Sep 20, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathreporter.js
More file actions
84 lines (74 loc) · 2.64 KB
/
Copy pathreporter.js
File metadata and controls
84 lines (74 loc) · 2.64 KB
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
'use strict';
module.exports = function(app) {
return function reporter(runner) {
function proxy(event) {
runner.on(event, function(data) {
app.sendClientEvent(event, data);
});
}
function onError(error) {
var response = {
suite: error.suite,
state: error.state,
browserId: error.browserId,
stack: error.stack || error.message
};
response.state.metaInfo = response.suite.metaInfo || {};
response.state.metaInfo.sessionId = error.sessionId;
response.state.metaInfo.file = response.suite.file;
app.sendClientEvent('err', response);
}
function onNoRefImage(data) {
app.addNoReferenceTest(data);
app.sendClientEvent('noReference', {
suite: data.suite,
state: data.state,
browserId: data.browserId,
currentURL: app.currentPathToURL(data.currentPath, data.browserId)
});
}
proxy('begin');
proxy('beginSuite');
proxy('beginState');
runner.on('testResult', function(data) {
var response = {
suite: data.suite,
state: data.state,
browserId: data.browserId,
equal: data.equal,
referenceURL: app.refPathToURL(data.referencePath, data.browserId),
currentURL: app.currentPathToURL(data.currentPath)
};
response.state.metaInfo = response.suite.metaInfo || {};
response.state.metaInfo.sessionId = data.sessionId;
response.state.metaInfo.file = response.suite.file;
if (data.equal) {
app.sendClientEvent('testResult', response);
return;
}
app.addFailedTest({
suite: data.suite,
state: data.state,
browserId: data.browserId,
referencePath: data.referencePath,
currentPath: data.currentPath
});
app.buildDiff(data)
.done(function(diffURL) {
response.diffURL = diffURL;
app.sendClientEvent('testResult', response);
});
});
runner.on('err', function(error) {
if (error.name === 'NoRefImageError') {
onNoRefImage(error);
} else {
onError(error);
}
});
proxy('skipState');
proxy('endState');
proxy('endSuite');
proxy('end');
};
};