forked from tajo/react-range
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage-reporter.js
32 lines (30 loc) · 878 Bytes
/
image-reporter.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
const fs = require('fs');
const imgur = require('imgur');
const clientId = 'ef1b6c91b9b66b8';
class ImageReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig;
this._options = options;
}
onTestResult(test, testResult, aggregateResults) {
if (
testResult.numFailingTests &&
testResult.failureMessage.match(/different from snapshot/)
) {
const files = fs.readdirSync(
'./e2e/__image_snapshots__/__diff_output__/'
);
files.forEach(value => {
imgur
.uploadFile(`./e2e/__image_snapshots__/__diff_output__/${value}`)
.then(function(json) {
console.log(`diff ${value} uploaded to ${json.data.link}`);
})
.catch(function(err) {
console.error(err.message);
});
});
}
}
}
module.exports = ImageReporter;