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
69 lines (63 loc) · 2.02 KB
/
Copy pathreporter.js
File metadata and controls
69 lines (63 loc) · 2.02 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
'use strict';
var _ = require('lodash');
function convertData(data) {
var result = _.omit(data, ['suite', 'state']);
if (data.suite) {
result.suiteId = data.suite.id;
result.suiteName = data.suite.name;
}
if (data.state) {
result.stateName = data.state.name;
}
return result;
}
module.exports = function(app) {
return function reporter(runner) {
function proxy(event) {
runner.on(event, function(data) {
app.sendClientEvent(event, convertData(data));
});
}
proxy('begin');
proxy('beginSuite');
proxy('beginState');
runner.on('endTest', function(data) {
var response = {
suiteId: data.suite.id,
stateName: data.state.name,
browserId: data.browserId,
equal: data.equal,
referenceURL: app.refPathToURL(data.referencePath),
currentURL: app.currentPathToURL(data.currentPath)
};
if (data.equal) {
app.sendClientEvent('endTest', response);
return;
}
app.addFailedTest({
suiteId: data.suite.id,
stateName: data.state.name,
browserId: data.browserId,
referencePath: data.referencePath,
currentPath: data.currentPath
});
app.buildDiff(data)
.done(function(diffURL) {
response.diffURL = diffURL;
app.sendClientEvent('endTest', response);
});
});
runner.on('error', function(error) {
app.sendClientEvent('error', {
suiteId: error.suite.id,
stateName: error.state.name,
browserId: error.browserId,
stack: error.stack || error.message
});
});
proxy('skipState');
proxy('endState');
proxy('endSuite');
proxy('end');
};
};