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
77 lines (69 loc) · 2.34 KB
/
Copy pathreporter.js
File metadata and controls
77 lines (69 loc) · 2.34 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
<
8E50
div data-line-number="28" class="react-line-number react-code-text" style="padding-right:16px">2829
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
'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) {
app.sendClientEvent('err', {
suite: error.suite,
state: error.state,
browserId: error.browserId,
stack: error.stack || error.message
});
}
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('endTest', 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;
if (data.equal) {
app.sendClientEvent('endTest', 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('endTest', response);
});
});
runner.on('err', function(error) {
if (error.name === 'NoRefImageError') {
onNoRefImage(error);
} else {
onError(error);
}
});
proxy('skipState');
proxy('endState');
proxy('endSuite');
proxy('end');
};
};