forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videos.js
42 lines (31 loc) · 1.22 KB
/
videos.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
import VideoRecorder from './index';
export default class Videos {
constructor (browserJobs, { videoPath, videoOptions, videoEncodingOptions }, warningLog, timeStamp) {
const options = { timeStamp: timeStamp, ...videoOptions };
this.recordings = {};
browserJobs.forEach(browserJob => {
const recorder = this._createVideoRecorder(browserJob, videoPath, options, videoEncodingOptions, warningLog);
recorder.on('test-run-video-saved', args => this._addTestRunVideoInfo(args));
});
}
getTestVideos (test) {
const rec = this.recordings[test.id];
return rec ? rec.runs : [];
}
_createVideoRecorder (browserJob, videoPath, options, videoEncodingOptions, warningLog) {
return new VideoRecorder(browserJob, videoPath, options, videoEncodingOptions, warningLog);
}
_addTestRunVideoInfo ({ testRun, videoPath, singleFile }) {
const testId = testRun.test.id;
let rec = this.recordings[testId];
if (!rec) {
rec = { runs: [] };
this.recordings[testId] = rec;
}
rec.runs.push({
testRunId: testRun.id,
videoPath,
singleFile
});
}
}